weixin_33738555 2019-02-10 20:24 采纳率: 0%
浏览 61

语法错误:意外令牌<

While customizing my site, I have made numerous changes and it looks like I messed up somewhere but I can't what went wrong. I would much appreciate any help here.

Here is what's happening, before logging in to my account (as a customer) I can add products into my cart without any problem. However, once I login then every-time I try to add a NEW product into the cart I get an error message

SyntaxError: Unexpected token <

or

SyntaxError: Unexpected token <

/ext/posc_ajxcart/js/posc_ajxcart_functions.js:91:43 Object.error()

ext/jquery/jquery.js:2:27449 i()

ext/jquery/jquery.js:2:28213 Object.fireWith as rejectWith

ext/jquery/jquery.js:4:22746 y()

ext/jquery/jquery.js:4:26925 XMLHttpRequest.c()

and even though I get the error message the product is added to the cart. After I refresh the page, and since that product is already in the cart, the error goes away and I can add more of the same product to the cart.

So any product that is not yet in the cart will return this error the first time it is added to the cart, and again this happens only if I'm logged in as a customer.

and the above /ext/posc_ajxcart/js/posc_ajxcart_functions.js:91:43 Object.error() refers to:

var err = eval("(" + xhr.responseText + ")");

Here is the code and thank you in advance.

function poscExtraBtnLink($products_lst){
if (POSC_AJXCART_STATUS == 'True') {
    $products_id = $products_lst['products_id'];
    if(tep_has_product_attributes($products_id)==1){
        return 'onclick="setPoscShowOptions(this, \''.$products_id.'\', \''.tep_href_link(FILENAME_DEFINE_POSC_AJXCART,'products_id='.$products_id).'\'); return false;"';
    }else{
        return 'onclick="setPoscAjxAddCart(this, \''.$products_id.'\'); return false;"';
    }
}
return false;
}


//set AjxAddtoCart
function setPoscAjxAddCart(e, products_id, action, qty, d, t){
var action = action || 'add';
var qty = qty || '1';

setPoscAjxloaderClass(e, 'add', t);
try {
    jQuery.ajax({
        type : 'POST',
        url  : posc_ajxcart_file,
        dataType : 'json',
        data : (((typeof d!="undefined") && d!='')? d:{'posc_action': action,'products_id': products_id, 'qty': qty}),
        success :function(data){
            setPoscAjxData(e, data, action);
            setPoscAjxloaderClass(e, 'remove', t);
        },
        error: function(xhr, textStatus, errorThrown) {
            var err = eval("(" + xhr.responseText + ")");
            setPoscAjxQck(e, "Error: " + xhr.status + ": " + xhr.statusText);
            setPoscAjxloaderClass(e, 'remove', t);
        }
    });
} catch (e) {
}
return false;

}

  • 写回答

1条回答 默认 最新

  • 游.程 2019-02-16 05:04
    关注

    Gladly, I finally found this error and wanted to share here in case someone else faces similar issue. Like I have stated in my initial post above, I was getting the SyntaxError: Unexpected token < error only after the client was logged in.

    So basically what was happening was that I had a typo in an SQL query (instead of manufacturers_id I had manufacturer_id), which was being executed when a customer was logging in.

    When the logged in customer was trying to add a new item in the cart, the INSERT query was returning an error and the jQuery was not showing the error.

    Hope this will help someone.

    Thank you.

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?