I am developing a native application in Android with PhoneGap. and I have created a Websevice in Visual Studio (c#) that will return an XML fragments. so I have converted the returned XML value into JSON, and have it tested in Mozilla firefox. but when i tried to however invoke the Webservice using AJax with Jquery. i tried encoding an alert message that will return the data of the service. however it seems not to return any data. can anyone please help me on this? thanks
here is my code:
$.ajax({
type: "POST",
url: "http://10.0.2.2:49878/a.aspx?p_trxn_type=doLogin&p_phoneNumber="+phoneNumber,
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert("error");
},
dataType : "json",
cache:false,
async:false,
success: function (ret)
{
try {
var jsonObj = eval('(' + ret + ')');
alert(jsonObj.Contacts.Contact['@phoneNumber']);
alert(jsonObj.Contacts.Contact.LastName);
alert(ret.Contacts.Contact['@phoneNumber'])
alert(ret.Contacts.Contact.LastName);
}
catch(ex) {
alert(ex.message);
}
console.log(ret);
alert(ret.length);
alert(ret);
alert(typeof ret);
alert("success");
}
});