newBie
newBie

Reputation: 118

Webservice in PhoneGap

I am a newbie to phonegap. I m stuck. I m unable to get result while calling webservice in phone gap. I used both Ajax and getJSON Method. Getting result as undefined, RealData variable as undefined. I am feeling that I am missing something. Please help guys.
Here is my code....

function onDeviceReady() {

    console.log("Device is Ready111111");
    alert("alert Device ready");

    /*var jqxhr = $
                .getJSON(
                'http://www.infoline.in/mobdata.aspx?
                                          reqfor=area_list&city=ahmedabad',
                        function() {

                            console.log("Device is Ready111111....."+jqxhr);
                            alert('success');
                        }).error(function() {
                    alert('error');
                });*/
    $(document).ready(function () {
        $.ajax({

            url: "http://www.infoline.in/mobdata.aspx",
            data: {
                "reqfor": "area_list",
                "city": "ahmedabad"
            },
            crossDomain: true,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg, textStatus, jqXHR) {
                alert(textStatus);

                var theRealData = msg.d;
                alert(theRealData.length)
            }
        });
    });

Upvotes: 0

Views: 475

Answers (1)

Malek Hijazi
Malek Hijazi

Reputation: 4162

In order to view the Object you have to convert the msg into a string.

try this:

console.log(JSON.stringify(msg));

Upvotes: 1

Related Questions