2011-09-07 105 views
0

我想调用一个.net webservice,它是由我的本地机器从jQuery .ajax()托管的。 该脚本包含在静态.html文件中。 成功函数被触发,但响应数据为NULL。jQuery Ajax响应:成功获取响应为空

 $.ajax({ 
      type: "GET", 
      data: '{continent: "' + $('#txtContinent').val() + '"}', 
      url: "http://localhost:60931/Service1.asmx/GetCountries", 

      contentType: "application/json; charset=utf-8", 
      dataType: "json", 
      success: function(response) { 

      alert(response); 

      }, 
      failure: function(msg) { 

       $('#result').empty().append(msg); 
      } 
     }); 

当我提醒它给我空的响应, 谁能告诉我在哪里IM提前布莱恩错了,谢谢。

+0

你已经安装Firebug的,或者(如果你使用的是Chrome),你看在开发工具的控制台调试Ajax调用? –

回答

1

这是因为你可能是从一个不在http://localhost:60931/的静态页面调用ajax。你可以把静态HTML放在本地主机上,并尝试通过相同的URL运行它。或者你也可以通过添加

error : function(xhr,status,error){ 
    alert(status); 
}, 
+0

谢谢Shameer它的工作.. –