I want to show data that returned from controller, in onComplete function:
function onComplete() {
alert(); //I want to show data that returned from controller in this.
}
here is ajax link:
@Ajax.ActionLink("Upvote", "Upvote", "Author",
new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "vote_count",
OnComplete = "onComplete",
})
And my controller:
public ActionResult Upvote(Guid QuestionID)
{
return Content("Message");
}
Thanks.
Or if you use the
OnSuccesscallback:you could:
For example if your controller action returned a JSON result:
in your Success callback you already get a javascript parsed object:
Notice that this is not the case with the
OnCompletecallback where you always get the XHR object as parameter and it is up to you to do the parsing and so on. Also notice that the OnComlpete callback is always executed, even if the AJAX call fails which obviously is not the case with the OnSuccess callback.