mat*_*att 2 forms ajax jquery post
我有以下三个变量:
var action,
pubMode,
token;
Run Code Online (Sandbox Code Playgroud)
所有三个值都应该通过POST和ajax提交.由于POST不接受网址,我完全不知道怎么做?
function ajaxPost(action, pubMode, token) {
$.ajax({
url: ??,
dataType: "text json",
type: "POST",
success: function(jsonObject,status) {
console.log("function() ajaxPost : " + status);
}
});
}
Run Code Online (Sandbox Code Playgroud)
你能帮帮我吧!谢谢
$.ajax有一个data选项,您可以将变量作为对象或查询字符串传递.
POST不像GET那样将变量粘贴到URL上.使用您要发布到的URL url并用于data发送变量.
$.ajax({
url: 'http://your/url/here',
dataType: "text json",
type: "POST",
data: {action: action, pubMode: pubMode, token: token},
success: function(jsonObject,status) {
console.log("function() ajaxPost : " + status);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9902 次 |
| 最近记录: |