4
$('#loginForm').submit(function() {

        $("#loginsubmit",this).attr("disabled","disabled");
        var u = $("#loginemail", this).val();
        var p = $("#loginpassword", this).val();

        var postTo = 'http://www.example.com/login.php';

        if(u != '' && p!= '') {

        //navigator.notification.alert("not empty"+u, function() {});

                var apiurl = "http://www.mapyi.com/api/mapyi/client.php?"+"action=verlogin&pass="+p+"&email="+u;
                $.ajax({
                url: apiurl,
                dataType: 'jsonp',
                jsonp: 'jsoncallback',
                timeout: 5000,
                success: function(data){
                    navigator.notification.alert("not empty"+data);
                },
                error: function(msg){
                    navigator.notification.alert("ERROR"+msg);
                }
            });

        } /* end if u and p */

         //hide();
         //$('#homepage').show();
         return false;
     });

I have added access in phonegap.xml , also aupdate manifest.xml for android. The php response is in json :

               /* PHP CODE SErver side */


/* output in necessary format JSON */

header('Content-type: application/json');
echo json_encode(array('posts'=>$ret));

I do not know what I'm missing, It always shows the ERROR dialog box with output ERROR [object] [object]

**RESOLVED I solved it myself, I was not adding header information in php service. header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']); header('Cache-Control: no-cache, must-revalidate'); Thanks CODER DECODER ENCODER for your time **

Ayesha
  • 255
  • 2
  • 10

1 Answers1

0

You are request code are looking perfectly. I think you missed the json callback in the server side. Just return the server data like this,

echo $_GET['jsoncallback'] .json_encode(array('posts'=>$ret));
Akilan
  • 1,707
  • 1
  • 16
  • 30
  • RESOLVED I was not sending header information in php response header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']); header('Cache-Control: no-cache, must-revalidate'); – Ayesha Jun 22 '12 at 16:06
  • Thanks Coder Decoder Encoder, that was also the issue and fixed by adding jsoncallback with GET. – Ayesha Jun 22 '12 at 16:16