I am just trying to implement a REST-like application with PHP + jQuery.
In the very first attempt I started getting this error
PUT http://... 405 (Method Not Allowed)
I put this in the very first line of my PHP script
header("Access-Control-Allow-Orgin: *");
header("Access-Control-Allow-Methods: *");
And this is my jQuery code:
$(function(){
$.ajax({
url: 'localhost/myscript.php',
type: 'PUT',
success: function(response) {
//...
}
});
});
I did nothing special in terms of configuration. Why is my Ajax request getting rejected and how can I solve this?
Change:
$(function(){
$.ajax({
url: 'localhost/myscript.php',
type: 'PUT',
success: function(response) {
//...
}
});
});
To:
$(function(){
$.ajax({
url: 'http://localhost/myscript.php',
type: 'PUT',
success: function(response) {
//...
}
});
});
And:
Is
Access-Control-Allow-Origin
. NotAccess-Control-Allow-Orgin
header("Access-Control-Allow-Orgin: *");
To:
header("Access-Control-Allow-Origin: *");