Hello i am working on a PHP script and i am facing an issue that when i open the URL from browser it opens successfully but when try to make ajax request it gives me 404 Error. My Code is Following
jQuery.ajax({
url : "http://example.com/ajaxRequest/index.php",
method : "POST",
cache: false,
data : {
name : "Mohsin",
},
success : function(data){
alert(data);
},
});
Same URL opens in browser but gives 404 Error with ajax Request. i have also included
header('Access-Control-Allow-Origin: *');
in above script
Mention as cross domain request in your ajax. And also use jsonp
for cross domain requests.
url : "http://example.com/ajaxRequest/index.php",
method : "POST",
cache: false,
data : {
name : "Mohsin",
},
crossDomain:true, <---- add this line
dataType : 'jsonp', // also this line
success : function(data){
alert(data);
},