I'm sending an ajax request to my server that updates some data there. Request is sent with jquery's get
function. On success I'd like te perform some action, but unfortunately whole operation fails since server gives no response, even though firebug clearly shows 200 status:
$(".interests-delete").live("click", function(){
var id = $(this).attr('title');
var user_id = "100000717262400";
$.ajax({
type: "GET",
url: "http://dev1.gecoloco.com/rte/ilike.php?",
data: "u=" + user_id + "&d开发者_C百科=" + id,
dataType: "json",
success: function(response, status){
alert(status);
console.log(response);
getLikes();
}
});
return false;
});
It's very likely due to "same origin policy' which mandates your html should come from the same domain to which ajax call is issued. Try loading your html page not from file system but through the same server serving the ajax calls. It will work.
Your url looks a bit funny there. The part: "?&u=..." should be "?u=..."
Maybe something is wrong with your success function. It is possible you are getting a response but your javascript is crashing somewhere in your function.
I've experienced this before when I opened a page from the local file system in my browser, e.g. file:///C:/Users/Eason/Desktop/mailer/index.html
.
When this page attempts to make an AJAX request, it would cause that problem. When it's published on a web server (e.g. Tomcat) it would work.
This is a security restriction in the browser to prevent unsafe cross-domain traffic.
精彩评论