Accessing database object after AJAX call
Permalink
I would like to connect to a mysql database after a form submission. The form is handled through an AJAX call. I'm directing to a single page called "handlesearch". I added the single page like told in the documentation.
After form submission the message "Access Denied." was returned to me. Any help? Thanks in advance!
AJAX call
Single page named: handlesearch
After form submission the message "Access Denied." was returned to me. Any help? Thanks in advance!
AJAX call
$("#searchform").submit(function() { var url = "single_pages/handlesearch.php"; $.ajax({ type: "POST", url: url, data: $("#searchform").serialize(), success: function(data) { alert(data); }, error: function() { alert("Error!"); } });
Viewing 15 lines of 17 lines. View entire code block.
Single page named: handlesearch
Thanks for the quick reply.
I've looked into the documentation (JavaScript, jQuery and concrete5) that you suggested. But when simply running the following line in a tool file:
I get the message "Access Denied." There must be something i'm missing here..
I've looked into the documentation (JavaScript, jQuery and concrete5) that you suggested. But when simply running the following line in a tool file:
I get the message "Access Denied." There must be something i'm missing here..
Most likely guess, on minimal information, is that the tools url needs to be generated with the c5 helper. That way it will be processed by the dispatcher and c5 knows how much environment to set up for it.
Well i tried using the URL:
/tools/required/handlesearch.php
Instead of:
/tools/handlesearch.php
This does works..
/tools/required/handlesearch.php
Instead of:
/tools/handlesearch.php
This does works..
Dear Gregory,
How did you do in order to make that /tools/required/....php call work?
What should I do with my tools php file??
Thank you in advance
How did you do in order to make that /tools/required/....php call work?
What should I do with my tools php file??
Thank you in advance
The closest to what you are doing is to ajax call an actionXX method in the single page controller. This will just respond to the specific method in a minimal environment.
You could also look up making ajax calls to a tools file (which is my usual preference)
There is more in the documentation and howtos. There are some working examples in my AJAX lessons howto and associated addon - a bit tired these days, but still basically valid.
Depending on the context, you may also want to look up using the validation helper to validate a token.