Ram*_*san 3 html javascript ajax jquery
var id = 45;
$.ajax({
url :'url', // This URL response some HTML content
type: 'POST',
dataType: 'json',
data :{ID:id},
success:function(data)
{
console.log(data); // No Response here
},
error : function (error){
console.log(error); // error.responseText contain html content
}
});
Run Code Online (Sandbox Code Playgroud)
我通过 JQuery AJAX 渲染 HTML 内容。HTML 响应来自错误函数而不是成功函数。我这边有什么错误吗?
小智 5
使用 html 而不是 json 作为数据类型
datatype 属性指定您期望从服务器返回的数据类型
$.ajax({
url :'url', // This URL response some HTML content
type: 'POST',
dataType: 'html',
data :{ID:id},
success:function(data)
{
console.log(data); // No Response here
},
error : function (error){
console.log(error); // error.responseText contain html content
}
});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
1676 次 |
| 最近记录: |