javascript - C#/Asp.net Post Function Not Working -


okay, here code:

    var functionaddword = function () {      var dictionaryitem = { };     dictionaryitem.word = $('#newwordid').val().trim();     dictionaryitem.definition = $('#newdefinition').val().trim();     $.post("/word/", dictionaryitem, function (result) {         window.alert(result.word);     }); }; 

web api:

config.routes.maphttproute(               name: "add or edit word",               routetemplate: "word",               defaults: new { controller = "values", action = "post"}           ); 

controller:

[httppost]         public jsonresult<dictionaryitem> post([frombody] dictionaryitem word )         {             var dictionaryrepository = new dictionaryrepository();             dictionaryrepository.addoreditword(word);              var response = new dictionaryitem { word = word.word, definition = word.definition};             return json(response);         } 

i have button calls functionaddwork, work. dictionaryitem set properly, have tested well. $.post not call controller method properly, , can't find controller. been working on 2+ hours , can't figure out missing.

thank in advance, jay


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -