javascript - Asp.net MVC 4 getJson work for create but not for edit. Seems to have an odd url in edit -
i'm writing mvc 4 app, have javascript function support couple of cascading dropdowns. javascript in js file , i'm trying use both create , edit view. works great create view, doesn't work edit view. i've looked @ network traffic using ie's developer tools, , notice url create call correct, controller/myactionmethod. url edit call controller/edit/controller/myactionmethod.
i using default route config, it's seems have worked fine, haven't delved deeply.
any thoughts on why controller/edit/ preappended url in edit case? idea how fix it?
i'll post code if it's useful, thought don't understand urls , routing.
thanks
here javascript
$(function () { $.getjson("professiontypelist", function (data) { var items = "<option>---------------------</option>"; $.each(data, function (i, professiontype) { items += "<option value='" + professiontype.value + "'>" + professiontype.text + "</option>"; }); $("#professiontypeid").html(items); }) });
the following line
$.getjson("professiontypelist",
will generate url of form
http://domain.com/controller/actionname/professiontypelist
i.e. append professiontypelist
@ end of url.
you should try make explicit url complete path. in cshtml
file, can using @url.action("professiontypelist")
Comments
Post a Comment