Get data from ajax response

At school, I need to develop a Twitter client with ASP.NET.

In the application, I have a list of tweets with a link to delete. This link is created using the Ajax.ActionLink () helper, and I specified a callback function for the OnSuccess event.

This link is fine: the action is being executed, the callback is being triggered, BUT I cannot access the data sent in the Ajax response.

The callback receives only one argument. Here is a dump of this object:

>> Sys.Mvc.AjaxContext
$0: 0
$1: null
$2: Sys.Net.XMLHttpExecutor
$3: Sys.Net.WebRequest
$4: null

Where is my text answer? I know the answer has content (according to the Chrome developer tools) and I really want to access it.

Bonus: can the Ajax client automatically parse the response as JSON (the action returns JSON correctly using the JSON method)?

Thank!;)


. get_data .

. , MSDN... .: (

Ruby on Rails, .

!:)

+3
2

get_object() AjaxContext, javascript get_data(), . , OnSuccess , .

public ActionResult ReturnJson()
{
    return Json(new { TestMessage = "Hello, world!" }, JsonRequestBehavior.AllowGet);
}

...

<script type="text/javascript">
    function AjaxSuccess(obj) {
        alert(obj.TestMessage);
    }
</script>

@Ajax.ActionLink("Say Hi", "ReturnJson", new AjaxOptions() { OnSuccess = "AjaxSuccess" })
+2

, AJAX ( JavaScript XML), SJAX ( JavaScript XML).

AJAX responseText, , , , , , , .

SJAX .

ASP.NET, .

JavaScript: JavaScript - AJAX/SJAX - Script

0

All Articles