javascript - 错误:Unexpected Token < In Json At Position 0 Cs Cart 提交发布请求时
问题描述
我有一个 Ajax 发布请求,在我提交请求后我收到一个错误:Unexpected token < in JSON at position 0。
如果我使用没有 ajax 的表单,我可以提交表单并在控制器中获取请求。但我想使用 Ajax 请求仅重新加载 id 为“#my_id”的 div。
这是我的要求:
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>
为什么会出现这个错误?我能做些什么来修复错误?
谢谢。
解决方案
推荐阅读
- java - 使用 @ConfigurationProperties 进行嵌套或直接访问
- jdownloader - JDownloader2:为 Linkgrabber 格式化链接
- c++ - 为什么我最大的子方阵求和程序不能处理带有负数的小矩阵?
- angular - 错误:未加载运行时编译器:在 Angular 7 的生产构建中
- c# - 使用 UseCookiesAuthentication 来授权 MVC 控制器操作,它在本地工作,当应用程序部署在 azure 中时会出现问题
- javascript - 为什么这段代码不会污染 JavaScript 中的原型?
- amazon-web-services - 初始化权限被拒绝
- tensorflow - 在实现“快速权重”时手动更新自定义层中的矩阵的问题
- c# - 如何使用高级安装程序在不删除客户端数据库的情况下更新我的应用程序版本
- c# - Unity - 通过抵消重力创造一辆气垫车