2012-11-01 106 views
0

我的web网址是http://www.webservicex.net/globalweather.asmx的jQuery +跨域+ AJAX + Web服务调用

,操作GetCitiesByCountry

$.ajax({ 
      type: 'POST', 
      url: "http://www.webservicex.net/globalweather.asmx?op=GetCitiesByCountry", 
      data: "{'CountryName':'" + user + "'}", 
      contentType: "application/json; charset=utf-8", 
      dataType: "jsonp", 
      crossDomain: true, 
      success: function (msg, status) { 
       alert("successful"); 
       console.log(msg.d); 
      }, 
      error: function (msg, status) { 
       alert("failure"); 
       console.log("failure"); 
       console.log(msg); 
       $('#myplace').html("The status is " + status + " with msg= " + msg + " .<br />" + msg.statusText + " .<br />" + msg.responseText + " .<br />" + msg.status); 
      } 
     }); 

,但我得到了下面的错误。

The status is parsererror with msg= [object Object] . 
success . 
undefined . 
200 

当我把“印度”作为输入。

如何解决这个issue..thanks提前

+1

这不是JSONP服务。 – SLaks

+0

您无法使用JSONP进行POST,此外,您不能在不实施CORS的情况下跨域进行POST,而这在oldie中不起作用 –

+0

如何实现cors?如何检查服务是否是jsonp。 –

回答

2

我用得到JSONP实际上没有返回JSON响应的URL。 谢谢@SLaks

Click here 如果有人想尝试这个URL,则返回json。

+0

你是如何让它返回一个JSON响应,那么你的答案中的链接和你的Web服务链接之间的关系是什么 –