The 500 (internal server error) means something went wrong on the server’s side. It could be several things, but I would start by verifying that the URL and parameters are correct. Also, make sure that whatever handles the request is expecting the request as a POST and not a GET.

In my case, the problem is i am passing incorrect data to server.

Previously my code looks like:

var myKeyVals={device_id:"12345",device_type:"I",other_user_id:"1",page_index:"0",search_keyword:"A",user_id:"78615"};
$.ajax({
type : "POST",
url : "yourURl",
data : myKeyVals,
success : function(response) {
console.error("Success:"+JSON.stringify(response));
alert('Success:'+JSON.stringify(response));
},
error : function(e) {
console.error("Error:"+JSON.stringify(e));
alert("Error:"+JSON.stringify(e));
}
});

But correct code is:

var myKeyVals={device_id:"12345",device_type:"I",other_user_id:"1",page_index:"0",search_keyword:"A",user_id:"78615"};
$.ajax({
type : "POST",
url : "yourURl",
data : JSON.stringify(myKeyVals),
success : function(response) {
console.error("Success:"+JSON.stringify(response));
alert('Success:'+JSON.stringify(response));
},
error : function(e) {
console.error("Error:"+JSON.stringify(e));
alert("Error:"+JSON.stringify(e));
}
});

You may also like

Leave a Reply