It should be very simple. I have read a lot of posts about consuming web service cross domain and the use of JSONP, but there is something I am missing.
If I call the following URL in the WebBrowser, I can get my result: http://benfaniz.com.br/WebService.asmx/AAA_Buscar_Nome_Condominio?callback=?
To consume it using jQuery, I am using:
$(document).ready(function() {
var surl = "http://benfaniz.com.br/webservice.asmx/AAA_Buscar_Nome_Condominio";
$.ajax({
type: 'POST',
url: surl,
dataType: "jsonp",
success: function(msg) {
alert(msg.data);
},
error: function(xhr, status, error) {
alert("error");
}
});
});
Here is the JS Fiddle
But I keep getting error? What is the problem?
UPDATE
I can get the content of the URL using the following code (taken from here)
$(document).ready(function() {
var theUrl = "http://benfaniz.com.br/WebService.asmx/AAA_Buscar_Nome_Condominio?callback=?"
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET", theUrl, false );
xmlhttp.send();
});
Please, look at JS Fiddle