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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -