0

Actually I want to a call an php url with jQuery mobile ajax call in android phonegap. The possible outcomes of the url are

  1. if successs then -- valid
  2. if fails the -- Code:201

I am using this code but it is not working help me.

        var request = $.ajax({
            url : "http://URL.com/api/validate.php?user=myUser&password=myPassword",
            type : "GET"
        });

        request.done(function(msg) {
            $("#notification").text(request.val());
        });

        request.fail(function(jqXHR, textStatus) {
            alert("Request failed: " + textStatus);
        });
  • Are you getting an error? – Jasper Feb 19 '13 at 06:59
  • no if i am using $("#notification").text(request); then it is giving me [object object] But if I am using $("#notification").text(request.val()); It goes to success block but shows nothing. –  Feb 19 '13 at 07:01
  • See this question regarding JSONP: http://stackoverflow.com/questions/3897641/can-ajax-request-data-from-a-remote-server. – Austin Mullins Feb 19 '13 at 07:03
  • why don't you try with the java script Ajax call ? if you can use then i can share the code . – neeraj Feb 19 '13 at 07:03
  • @neeraj please give me I will try. –  Feb 19 '13 at 07:04

1 Answers1

1

Actually you can put those function in the ajax method

 $.ajax({
   url : "http://URL.com/api/validate.php?user=myUser&password=myPassword",
   type : "GET",
   success : function(data){/*yr code here*/},
   fail: function(){/*yr code here*/}
 });
Horst
  • 1,733
  • 15
  • 20
  • But I want to get values from server response also. –  Feb 19 '13 at 07:34
  • Thanks @fattomhk It worked for me...... But can u provide me some explanation. Thanks for helping –  Feb 19 '13 at 07:50
  • They are callback functions defined by jQuery, you may find more here: http://api.jquery.com/jQuery.ajax/ – Horst Feb 19 '13 at 08:16