user1482015
user1482015

Reputation:

cannot get ajax return and show it

I use jquery ajax to call a webmethod, I use Fiddler to debug and it show the webmethod has return json data. enter image description here

Here is my code:

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "Default.aspx/NewUserEvent",
                data: user_event_data_json,
                dataType: "json",
                success: function (new_user_event_id) { $("#testingspan").text(new_user_event_id.d); },
                error: function () { $("#testingspan").text("error"); }
            });
............
............
............
<div id="testingspan"></div>

I don't know why my browser can not show anything ? is my code has problems?

Upvotes: 2

Views: 65

Answers (1)

Crab Bucket
Crab Bucket

Reputation: 6277

Not every browser displays JSON 'out of the box'. Most need plugins. Try browsing with chrome. That definitely can display JSON. This article says more

http://www.west-wind.com/weblog/posts/2011/Apr/01/Displaying-JSON-in-your-Browser

Might help

Upvotes: 2

Related Questions