我的页面是domain.com/home/details/1ASP.Net MVC的路由问题jQuery的AJAX
在我的jQuery AJAX调用我见然而下面这让调用它的制作域呼叫时。 com/home/details/home/getdata
我该怎么做才能正确解决问题?
$(document).ready(function() {
oTable = $('#example').dataTable({
"bServerSide": true,
"sAjaxSource": "Home/GetData/",
"bProcessing": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"bFilter": true,
"bAutoWidth": false,
"fnServerData": function (sSource, aoData, fnCallback) {
/* Add some extra data to the sender */
//aoData.push({ "filtervalue": $('#filtervalue').val(), "Options": $('#Options').val() });
$.getJSON(sSource, aoData.concat($('form').serializeArray()), function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
});
}
});
});
+1表示助手。如果您在虚拟目录(例如http://domain.com/myapp/)中部署应用程序,则使用'/ Home/GetData'将不起作用。 –
建议总是使用URL帮助器,永远不要硬编码URL。 – IAbstract