Click here to Skip to main content
15,885,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
function GetData() {
    var url = "http://localhost:60191/SampleService.asmx/SayHello";
    $.ajax({
        type: 'GET',
        url: url,
        crossDomain: true,
        contentType: "application/json; charset=utf-8",
        //data: "{firstName:'Aidy', lastName:'F'}",
        dataType: "jsonp",
        timeout: 4000,
        async: false,
        success: function (data) {
            debugger;

            var aa = JSON.parse(data);
            alert(data);
            $.each(msg, function (name, value) {
                alert(value);
                console.log(data.data);
            });
        },
        error: function (xhr, status, error) { alert('error 404 !!'); },
        async: false,
        cache: false
    });
}
Posted
Updated 17-Mar-15 20:00pm
v2
Comments
Mohibur Rashid 18-Mar-15 3:16am    
alert the data before you parse with json parse. It seems your PHP(guessed it, without any valid reason) has an error. I can be wrong too.

1 solution

It could be caused by your JSON.parse.

You do not need it. If the server tells jQuery the awnser is application/json. Or you tell jQuery it is dataType: "jsonp",
jQuery will parse the data for you.

So now you are parsing a javascript object.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900