1

在我的应用程序中,我使用简单的 Jquery Ajax 调用,但它不起作用。这是我的代码

      try{
          $.ajax({
               type: "GET",
               url: "http://xxxxxxx/sites/weed/chkuseremail_response.php?user_name=hhhhh&type=user&email=test@test.com",
               async: false,
               success: function(result) {
                        alert("result "+result);
                        alert("result.response "+result.response);
                        alert("result.error "+result.error);

                                  var error = result.error;
                                  var response = result.response;
                                  if (error == null || error == "null") {
                                      alert("welcome1");
                                  }
                                  if (response == null || response == "null") {
                                       alert("welcome2");
                                  }

                                  },
                                       error: function() {
                                              alert("welcome3");
                                              }
                                       });

           }catch(e)  {alert(e);

}    

我正在使用罗德 3.0.2。

4

1 回答 1

0

这是因为跨域策略限制。

当您浏览网站时,出于安全原因,浏览器会禁用对其他主机的 ajax 调用。

Rhodes 应用程序也发生了同样的事情,您不能调用不在应用程序的同一域上运行的 Web 服务。

您可以使用JSONP来获取外部 JSON 数据。

于 2011-09-15T13:37:19.730 回答