jqueryajaxrhomobilerhodes

Jquery Ajax call not working in Rhodes


In my application i am using simple Jquery Ajax call, but it is not working. Here is my code

      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);

}    

I am using rhodes 3.0.2.


Solution

  • This is because of cross-domain policy restrictions.

    When you're browsing a site, for security reasons, ajax calls to other hosts are disabled by the browser.

    The same thing is happening for your Rhodes application, you can't call a web service that's not running on the same domain of your application.

    You can use JSONP to be able to get external JSON data.