gpt4 book ai didi

jquery - ajax响应总是报错

转载 作者:行者123 更新时间:2023-12-01 03:39:01 25 4
gpt4 key购买 nike

我的ajax响应有一些问题,我的ajax代码给出了正确的结果,但在ajax代码中它总是处于错误状态。

这是我的ajax代码

 $.ajax({
type: "POST",
url: baseURL+"top_ten_wikilerter",
dataType: "json",
success: function(resp){
alert('success');
},
error: function(resp){
alert('eror');
}
});

当我在 php 端打印结果时,它给出

<div class="row tpbtm-pdng brdr-btm">
<a href="#">
<div class="col-md-5">
<div class="col-md-2"><img src="/assets/images/users/user1.png" class="img-circle" /></div>
<div class="col-md-10">Sandy</div>
</div>
<div class="col-md-7" id="rght-sd-icn">
<div class="col-md-2"><span ref="tooltip" data-toggle="" data-placement="top" title="This user has reported 7 alerts">
<img src="/assets/images/icons/alert.png"/>
<span>7</span>
</span>
</div>
<div class="col-md-2">
<span ref="tooltip" data-toggle="" data-placement="top" title="This user has reviewed 2 alerts">
<img src="/assets/images/icons/copy-search.png" />
<span>2</span>
</span>
</div>
<div class="col-md-3"><span ref="tooltip" data-toggle="" data-placement="top" title="This user has informed or help to inform 2 users">
<img src="/assets/images/icons/find-frnd.png" />
<span>2</span>
</span>
</div>
<div class="col-md-5"><img src="/uploads/user_type_icon/Graduate1410251236.png" /><span class="dmigd-text">Graduate</span>
</div>

</div>
</a>
</div>

在 php end 中执行代码后,它给出结果,但在 ajax 响应中它始终处于错误状态。

最佳答案

数据类型应该是html而不是json,因为您得到的响应是html而不是>json 所以正确的ajax请求如下所示:-

 $.ajax({
type: "POST",
url: baseURL+"top_ten_wikilerter",
dataType: "html",
success: function(resp){
alert('success');
},
error: function(resp){
alert('eror');
}
});

关于jquery - ajax响应总是报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26140458/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com