jquery - setting up controller for ajax post call -
after finding , figuring out problem in previous code, realized controller page has been blocking call it. know nothing how code in vb, that's project based in. i'm searching make sure controller page set recieve post call ajax function.
jquery code
$('#vehicle_kovid_value').change(function () { var kovid = $(this).val(); alert("hello!"); if (kovid != null && kovid != '') { $('#vehicle_bodystyle_value').get(0).options.length = 0; $('#vehicle_bodystyle_value').get(0).options[0] = new option('please select one', '-1'); $.ajax({ type: "post", url: '/projectname/controllers/ajaxcontroller/index', async: true, data: { kovid: kovid }, contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { $('#vehicle_bodystyle_value').get(0).options.length = 0; $('#vehicle_bodystyle_value').get(0).options[0] = new option("please select one", "-1"); alert("worked!"); $.each(msg.d, function (index, item) { $('#vehicle_bodystyle_value').get(0).options[$('#vehicle_bodystyle_value').get(0).options.length] = new option(item.display, item.value); }); }, error: function () { $('#vehicle_bodystyle_value').get(0).options.length = 0; $('#vehicle_bodystyle_value').get(0).options[0] = new option("error!", "-1"); alert("failed load styles"); } }); } }); controller class
<acceptverbs(httpverbs.post), authorize> _ function index() actionresult return view() end function i recieving error when viewing program in firebug:
the http verb post used access path '/projectname/controllers/ajaxcontroller/index' not allowed. i don't know vb, , haven't found helpful pages or questions how can build controller call @ least hits breakpoint @ function. understand function not work right now. i'm concerned controller not accepting call @ , therefore not hitting breakpoint.
any tips or advice helpful, or links pages may assist in this. thank in advance suggestions!
i figured out problem. had remove datatype: "json"; , worked perfectly.
i had change type: "post"; type: "get"; or wasn't calling properly.
Comments
Post a Comment