javascript - When sending jQuery post to MVC controller getting 404 error -


i'm sending view using jquery mvc post action

function dosomething(passedid) {    $.ajax({              method: "post",              datatype: 'text',                                     url: '/mycontroller/someaction/',              data: { id: passedid}           }).done(function (data) {               //                           }); } 

and inside mycontroller

 [httppost]  public actionresult someaction(int id)  {      ...  } 

in firebug console i'm getting 404 error.

you didn't said version of jquery using. please check jquery version , in case version < 1.9.0 should instead of

method: "post"  

use

type: "post" 

this alias method, , according jquery official documentation should use type if you're using versions of jquery prior 1.9.0.

function dosomething(passedid) {         $.ajax({              type: "post",              datatype: 'text',                                     url: '/mycontroller/someaction/',              data: { id: passedid}            }).done(function (data) {                                                        ...           }); } 

tested above code , works (each request enter inside mvc controller http post someaction action).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -