简体   繁体   English

语法错误:json 中位置 0 的意外标记 <

[英]syntaxerror : unexpected token < in json at position 0

I have a problem in the opencart cart page , whenever the user want to remove an item from the cart the below massage is displayed我在 opencart 购物车页面中遇到问题,每当用户想要从购物车中删除项目时,就会显示以下消息

syntaxerror : unexpected token < in json at position 0
ok 
<pre>remove</pre>{"total":"0 item(s)-0.000 BD"}

i believe that我相信

remove
should not be here , but unfortunately i couldn't find it in the files , any idea ? 不应该在这里,但不幸的是我在文件中找不到它,知道吗?

Seems that your output should be json format, however you're printing those <pre>remove</pre> as well, which makes your json invalid.似乎您的输出应该是 json 格式,但是您也在打印那些<pre>remove</pre> ,这使您的 json 无效。

Maybe You could try to use some grep in order to locate the file where those strings are coming from.也许您可以尝试使用一些grep来定位这些字符串来自的文件。

I know nothing about opencart... but your problem is that <pre>remove/pre> is "outside" of the json object, it must to be some thing like:我对 opencart 一无所知......但你的问题是 <pre>remove/pre> 是 json 对象的“外部”,它必须是这样的:

{"total":"0 item(s)-0.000 BD", "the_pre":"<pre>remove</pre>"} 

What I think is that you have a php code that is making an echo when you make this request (ajax request?) before arrive to the json object output.我认为您有一个 php 代码,当您在到达 json 对象输出之前发出此请求(ajax 请求?)时,该代码正在发出回声。

i found the solution to this problem我找到了这个问题的解决方案

in system/library/cart.php在系统/图书馆/cart.php

under : public function remove($cart_id) delete the follwing :在 : public function remove($cart_id)删除以下内容:

   echo "<pre>";
            print_r("Remove");
            echo "</pre>"; )

that shall fix the problem这将解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM