I have an Ajax.ActionLink
inside a PartialView
like so:
@Ajax.ActionLink(Model.IsVisible ? "Disable" : "Enable", "ToggleVisibility", "Review", new { area = "Admin", id = Model.Id }, new AjaxOptions { HttpMethod = "POST", OnComplete = "onComplete_AdminReviewOption" })
And the handling JavaScript function (declared in-line on the main View for now):
function onComplete_AdminReviewOption(ajaxContext) {
var jsonObject = ajaxContext.get_object();
}
Which throws a javascript error:
Object# has not definition for get_object()
.
I thought these JavaScript methods were part of the MicrosoftAjax.js
/ MicrosoftMvcAjax.js
scripts, both of which i have included on my page.
Can anyone confirm which library these helper methods are present?
I load the required scripts in my Layout.cshtml
file, then i do an AJAX call to render out the above PartialView.
So by the time i handle that function, the libraries are already loaded - which is why im confused.
Any ideas?
It looks like you are using ASP.NET MVC 3 and Razor. In this version jQuery is the default client scripting framework. No more
MicrosoftAjax.js
(thanks God). So:Also don't forget to include
jquery.unobtrusive-ajax.js
.If you want to use the legacy stuff you could by setting the following in your web.config:
By default this variable is set to true.
Personally I prefer to use standard links:
and AJAXify them using jQuery in a separate javascript file: