php - jQuery AJAX return 404 error -
i try use ajax send form data server, returns me 404 time. here code:
$(function() { var datastring ='name: '+conditionname+"&desc: "+conditiondescription+'&condition: '+condition; //alert (datastring);return false; $.ajax({ type: "post", url: "savecondition.php", data: datastring, success: function(response) { alert ('data saved: '+datastring); }, error: function (xhr, ajaxoptions, thrownerror) { alert(xhr.status); } }); return false; });
"savecondition.php" in same folder .js file use wamp server on local machine.
update:
when changed path "savecondition.php" relative html page, got error 500
the path of url requested ajax relative root of page you're on, i.e. if page in root directory (let's call index.html) along ajax script (data.php), , jquery script in js directory, use 'data.php' url. if data.php script in js directory, url need 'js/data.php'.
be careful using relative paths. it's best use absolute paths, in case script used different directory, other path developed within.
you mention 500 response code. indicates php script you're requesting in fact erroring out.
in order find out cause of error, either check error logs or place below code php script. error output in http response body.
ini_set('display_errors', 'on'); error_reporting(e_all);
Comments
Post a Comment