
正文
在chrome console中添加jQuery
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
由于现有seajs等封装,jQuery等已不在全局暴露,即使网站中已使用jQuery,在console也使用不了。
在chrome中可以用以下代码加入jQuery:
fetch('//code.jquery.com/jquery-latest.min.js').then(r => r.text()).then(r => eval(r))
POST JSON 数据:
jQuery.ajax({
"url":"/someurl",
"method":"POST",
"headers": { "Content-Type": "application/json"},
"dataType":"JSON",
"processData":false,
"data":JSON.stringify({}),
"success": function(data){
console.log(data);
copy(data);
}
})
POST application/x-www-form-urlencoded 数据
jQuery.ajax({
"url":"/url",
"method":"POST",
"dataType":"JSON",
"data": {"key": "value"},
"success": function(data){
console.log(data);
}
})
或
jQuery.ajax({
"url":"/url",
"method":"POST",
"dataType":"JSON",
"processData":false,
"data": jQuery.param({"key": JSON.stringify(object)}),
"success": function(data){
console.log(data);
}
})
来自: stackoverflow





