asp.net mvc - Success and Error functions not firing in Ajax call -


below ajax call i'm using determine menu options show users (i know it's flawed method, against time crunch demo). when page loads, can step through controller method in visual studio know it's hitting controller , sending right information.

looking @ chrome's network console can see browser received right response. however, neither console.log or alert firing. nothing in success or error methods executed either. see what's going wrong?

view

    $(document).ready(function ($) {         //determine links show in navbar         window.onload = function () {             $.ajax({                 type: 'get',                 url: '@url.action("checksecurity","home")',                 datatype: 'json',                 succcess: function (data) {                     console.log(data);                     alert(data);                     if (data == "admin") { $('#adminlink').show(); }                     else if (data == "it") { $('#itlink').show(); }                     else if (data == "viewer") { $('#viewerlink').show(); }                     else if (data == "modifier") { $('#modifierlink').show(); }                 },                 error: function (data) {                     alert("error");                 }             });         }; 

controller

    [httpget]     public jsonresult checksecurity()     {         if (security.isadmin(user)) return json("admin", jsonrequestbehavior.allowget);         if (security.isitsupport(user)) return json("it", jsonrequestbehavior.allowget);         if (security.isviewer(user)) return json("viewer", jsonrequestbehavior.allowget);         if (security.ismodifier(user)) return json("modifier", jsonrequestbehavior.allowget);          return json("na", jsonrequestbehavior.allowget);     } 

here couple screen shots of network , regular console in chrome. bother after i've stepped through controller method , program has returned value browser.

network console

enter image description here

standard console

enter image description here

there c in

succcess:

so response 200 request , because have no mapping success defined, never logged


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -