P.K. P.K. - 2 years ago 146
Javascript Question

how to call Javascript method from MVC4 link (error JavaScript runtime error: Object doesn't support this action)

I have a javascript code which should be started after clicking on link on view page, but the error is displayed. What is wrong?
Error is: '
0x800a01bd - JavaScript runtime error: Object doesn't support this action'

Javascript code:

var MenuController = function () {

MenuController.prototype.Logout = function () {

type: "GET",
url: '/Account/Logout',
success: function (response) {
alert('log out');


HTML code:

<a onclick="new MenuController.Logout();" alt="Log out">Log out</a>
<script src="/js/Controller/MenuController.js" type="text/javascript"></script>

Answer Source

You're missing the brackets to construct the MenuController. new MenuController.Logout(); should become new MenuController().Logout();

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download