function createSuccess(context) {
$get(“result”).innerHTML = context.get_data();
}
<% using (Ajax.BeginForm(new AjaxOptio开发者_运维问答ns {OnSuccess="createSuccess"}))
{%>
What does context holds in the createsuccess method? data return by controller? How do we return json data in the createsucess if so
The success callback, as well as any other callbacks you can specify in the AjaxOptions object, receives only one argument of type AjaxContext. To get the response as plain data, call the get_data method. if it is html content, you can directly set the data to the element using innerHtml. If it is JSON, pass it through the JavaScript's eval function to transform a JSON string into a usable JavaScript object.
AjaxContext has followin functions get_data -> Gets any data returned from the controller action.
get_insertionMode ->Indicates how to treat the response (only if markup), whether to replace, prepend, or append it to the markup of the specified DOM element. The default is replace.
get_loadingElement ->Indicates the DOM element to be displayed to indicate that an AJAX call is going on.
get_request ->Gets the Sys.Net.WebRequest object that represents the current request.
get_response -> Gets the Sys.Net.WebRequestExecutor object for the current request.
get_updateTarget ->Indicates the DOM element to be automatically updated with the returned markup, if any.
For more information, see http://www.devproconnections.com/article/aspnet2/ajax-features-in-asp-net-mvc.aspx
精彩评论