嗨,有没有办法从帖子中获取请求,以便我可以打印它?
例如,我想得到这个(登录服务器)。
/App/user/?email=phe@mail.com&dob=Fri Oct 05 2012 10:23:25 GMT+0200 (CEST)&childPortions=&tips=on&firstName=]
我知道有这方面的工具,但我现在对此并不感兴趣。
$.ajax({
type: 'POST',
url: "/App/user/",
data: profile,
cache: false,
success: function(data){
$(".response-container").html(JSON.stringify(data, null, 2));
}
});
这看起来很有趣(jQuery.param())
data 选项可以包含 key1=value1&key2=value2 形式的查询字符串,或 {key1: 'value1', key2: 'value2'} 形式的映射。如果使用后一种形式,则数据在发送之前使用 jQuery.param() 转换为查询字符串。可以通过将 processData 设置为 false 来规避此处理。如果您希望将 XML 对象发送到服务器,则该处理可能是不可取的;在这种情况下,将 contentType 选项从 application/x-www-form-urlencoded 更改为更合适的 MIME 类型。
编辑: .ajaxSend 永远不会被执行。调用成功函数。这怎么会发生?
$(document).ajaxSend(function(e, jqXhr, options) {
alert("hallo");
});
$.ajax({
type: 'POST',
url: "/App/user/",
data: profile,
cache: false,
success: function(data){
console.log("ajax sent!")
}
});