jquery - Ajax call throwing an error but I see response on Fiddler -


my page using ajax call username. see response in fiddler still throws error.

here code:

$.ajax({                type: "post",                url: "selection.aspx/getuser",                data: "{}",                contenttype: "application/json; charset=utf-8",                datatype: "json",                success: function (response) {                    var username = response.d;                    if (username.indexof("error") > 0) {                        jalert(username);                    }                    else                    {                        if( username!= "" )                         {                            $("#maincontent_lbluser").text(username);                        }                    }                 },                error: function (xhr, status, error) {                    if (xhr.responsetext != "") {                        var err = eval("(" + xhr.responsetext + ")");                        jalert(err.message);                    } else                        jalert('unable user', 'ajax error', null);                }            }); 

i see alert "unable user". in fiddler see {"d":"domain\crm.admin"}

any appreciated.

make sure returning json object. if aren't sure edit datatype specification , add code in success callback; example:

$.ajax({                type: "post",                url: "selection.aspx/getuser",                data: "{}",                contenttype: "application/json; charset=utf-8",                                  success: function (response) {                    newresponse = jquery.parsejson(response);                    var username = newresponse.d;                    if (username.indexof("error") > 0) {                        jalert(username);                    }                    else                    {                        if( username!= "" )                         {                            $("#maincontent_lbluser").text(username);                        }                    }                 },                error: function (xhr, status, error) {                    if (xhr.responsetext != "") {                        var err = eval("(" + xhr.responsetext + ")");                        jalert(err.message);                    } else                        jalert('unable user', 'ajax error', null);                }            }); 

i hope helps


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -