I have a jQuery Ajax Post request which goes into a Code Igniter function, after which CodeIgniter sends an email with details in the post request.
JavaScript Code:
$.ajax({
type: 'POST',
url: 'http://localhost/admin/index.php/callback',
data: { 'name': inputName, 'phone': inputNumber},
success: function() {
onSuccess();
},
async:true
});
PHP/CodeIgniter function
public function email() {
if (!isset($_POST)) {
//exit('No direct script access allowed');
} else {
//Send Email
}
}
The Problem SEE EDIT
CodeIgniter does not send a response to the call.
The Post request is recieved and run as the email part works fine, I recieve the email with the details sent in the post request but onSuccess(); is never called (and no response is logged via Chromes network watcher, it just says 'Pending')
This is all ran off my local machine
This request is done from the main index.php BUT CodeIgniter is only installed in the /admin directory
Thanks for your time!
EDIT: Changed the ajax url to the full url with localhost as that's how it's set in CI $config
EDIT: CI does send a response, it takes 2-3 minutes which is also how long it takes the email to be sent, in that time I cannot access any other pages of the site. I am starting to think this may be a problem with my local machine/Apache setup.
500 internal server error. Also try on Firebug to see if it hangs with no response like Chrome.error:to your ajax request and pop up an alert. This will prove that the problem is the controller and notonSuccess();