I want to Access php web service using ajax jquery
This is my code:-
$.ajax({
type: "POST",
url:'http://localhost:8080/onestatus/webservice/login?email=kk@kk.com&password=123456',
cache: false,
dataType: "json",
success: onSuccess
});
function onSuccess(data) {
// var data = data.d;
var result = $.parseJSON(data);
var arrayObject = new Array();
for (var i = 0; i < result.user.length; i++) {
// $('#resultLog').append('<li>' + result.user[i].user_id + '</li>');
}
}
when i use dataType: “json” then i am getting request.status=0 noting getting in responce
and when use dataType: “jsonp” getting error in firbug
SyntaxError: invalid label
[Break On This Error]
{“user”:[{“response”:”success”,”user_id”:”28″,”session_id”:123456}]}
Two cases:
http://localhost:8080/onestatus/webservice/loginis placed on a domain different from the requesting domain(note: the port must match too) : you will not be able to request a JSON, it’s restricted by SOPSo what you can do:
When the webservice is under your control, change the response to proper JSONP. Otherwise you can’t do anything.