Gau*_*rav 10 javascript jquery asp.net-mvc-3
在jquery中是否有任何方法,如$ .post,$ .ajax等,其工作方式与普通表单提交相同.我知道.submit()但它需要一个表单元素,我们可以在jquery中发送没有表单元素的正常请求吗?
Sam*_*son 23
您可以在没有表格的情况下提交$.ajax().此外,为了使其行为像普通形式一样,将async属性设置为false.
$.ajax({
url: "/controller/action",
data: {'foo':'bar'},
async: false
});
Run Code Online (Sandbox Code Playgroud)
这将导致您被发送到:
"/controller/action?foo=bar"
Run Code Online (Sandbox Code Playgroud)
Dar*_*rov 10
window.location.href = '/controller/action?foo=bar';
Run Code Online (Sandbox Code Playgroud)