Sending Data To Php Using Ajax
I have searched my problem before posting this question, but failed to find a solution. I need to send a json string to php file but unable to do so, can some one please help with
Solution 1:
The 500 (internal server error) means something went wrong on the server's side. So check the apache error log for more details
you may find apache log here /var/log/apache2/
Solution 2:
On client side (javascript code):
data: JSON.stringify(postData)
On server side (PHP code):
json_decode($_POST["data"])
Solution 3:
u commented the closing braces of the function with the return statement. change this :
//return JSON.stringify(postData);}
to:
//return JSON.stringify(postData);
}
Also :
data: JSON.stringify(postData),
IN update.php
$json = $_POST['myData'];
$result = json_decode($myData);
var_dump($result);
Solution 4:
Comment from @Tushar helped me resolving the issue
contentType: 'application/x-www-form-urlencoded; charset=UTF-8', data: {json: JSON.stringify(postData)
Solution 5:
sent Ajax request to php Page to Get data
$.ajax({ method: "POST", // it may be Get url: "some.php", //page where you sent request data: { name: "John", location: "Boston" } //attibutes you want to take on that page }) .done(function( msg ) { // sucessfull reponse alert( "Data Saved: " + msg ); });
Post a Comment for "Sending Data To Php Using Ajax"