Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  39] [ 5]  / answers: 1 / hits: 17118  / 12 Years ago, sun, october 28, 2012, 12:00:00

I am trying to call a PHP script using AJAX. I have put a simple echo alert in my deleteitem.php script to check whether it is getting called, but whatever I do, it does not get called. The PHP script is in the same folder as the js script that is calling it



Can someone tell me why that would be? What are the possible causes?



$.ajax({
url: 'deleteitem.php?task=deleteArtwork&id='+artworkObjectID,
type: POST,
dataType: html,
success: function(data)
{
//do something here
}
});

More From » php

 Answers
122

As Amitd said, you shouldn't combine GET and POST requests. The code should look like:



$.ajax({
url: 'deleteitem.php?task=deleteArtwork&id='+artworkObjectID,
type: GET,
dataType: html,
success: function(data)
{
alert(data); // alert on success
}
});


If you still don't get any response, there might be a server error, so you should put lines like this one in the .php script, at the beggining of the script:



error_log(script was called, processing request...);
error_log(passed artworkObjectId is: . $_GET[artworkObjectID]);


You can then check in your .log file (it can be found in the apache log file/folder if it's running on apache server) if there are any messages.


[#82312] Friday, October 26, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaelyn

Total Points: 619
Total Questions: 102
Total Answers: 104

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;