Javascript 错误:意外标记<;在提交post请求时位于位置0的Json中
我有一个Ajax post请求,在提交请求后,我得到一个错误:JSON中位置0处的意外标记< 如果我使用没有ajax的表单,我可以提交表单并在控制器中获取请求。但是我想使用Ajax请求只重新加载id为“#my_id”的div 这是我的要求:Javascript 错误:意外标记<;在提交post请求时位于位置0的Json中,javascript,php,ajaxform,cs-cart,Javascript,Php,Ajaxform,Cs Cart,我有一个Ajax post请求,在提交请求后,我得到一个错误:JSON中位置0处的意外标记
function getData(url, obj) {
var container = obj.parents('.cm-product-filters');
var params = {
method: 'post',
result_ids: ajax_ids,
save_history: false,
caching: false,
data: {
is_ajax: true,
features_hash: generateHash(container),
security_hash: s_hash
},
scroll: '#my_id',
obj: obj,
security_hash: s_hash,
callback: _getDataRespons
};
if (ajax_ids) {
$.ceAjax('request', url, params);
} else {
$.redirect(url);
}
return false;
}
表格:
<form
class="cm-ajax cm-product-filters"
method="post"
name="form_coffind"
enctype="multipart/form-data"
id="gform_5"
action="{""|fn_url}"
data-ca-target-id="my_id"
data-ca-base-url="http://localhost/public_html/cscart?dispatch=pages.view_products"
>
<input type="hidden" name="result_ids" value="my_id" />
<input type="hidden" name="redirect_url" value="http://localhost/public_html/cscart?dispatch=pages.view_products">
<div class="gform_body">
<ul
id="gform_fields_5"
class="gform_fields top_label form_sublabel_below description_below"
>
<li
id="field_5_6"
class="gfield gform_validation_container field_sublabel_below field_description_below"
>
<div class="ginput_container">
<input
id="button_cart_817"
class="ty-btn ty-btn__primary cm-submit"
type="submit"
name="dispatch[pages.view_products]"
value="Submit"
/>
</div>
</li>
</ul>
</div>
</form>
<div class="my_id cm-reload" id="my_id">
<!--my_id--></div>
-
为什么会发生这种错误?我可以做些什么来修复错误
谢谢。检查开发工具中的“网络”选项卡。AJAX处理程序可能出现问题。我已检查,并且所有请求的状态都为200。检查AJAX响应。响应JSON在那里,但我没有在javascript文件或smarty模板中获得响应。可能返回的JSON中包含HTML模板。检查原始JSON响应以确保它是纯JSON。如果不是,您需要确保您的JSON响应没有包装在HTML模板中。请检查dev工具中的网络选项卡。AJAX处理程序可能出现问题。我已检查,并且所有请求的状态都为200。检查AJAX响应。响应JSON在那里,但我没有在javascript文件或smarty模板中获得响应。可能返回的JSON中包含HTML模板。检查原始JSON响应以确保它是纯JSON。如果不是,则需要确保JSON响应没有包装在HTML模板中。