php – 在firebug中找到JQuery语法错误,但在我的代码中没有

PHP页面中,我有一个下拉列表,它触发jQuery更改功能并使用AJAX执行POST以填充页面中的第二个下拉列表.

它应该都非常简单,但Firebug会为’?’引发语法错误在运行时出现在我的代码中,实际上并不在我的代码中.

这是我的javascript代码

$(document).ready(function() {
    $('#taglist').change(function(){
        $.ajax({
            type: "POST",url: "../includes/ajax.PHP",data: "taglist=" + $(this).find("option:selected").attr('value'),dataType: 'json',success: function(response,textStatus,jqXHR) {
                $("#catlist").html(response.catlist);
            },error: function (xhr,errorThrown) {
                $("#catlist").html(xhr.responseText);
            }
        });​
    });
});

以下是在ajax.PHP中执行的PHP代码

if(isset($_POST['taglist'])){
    $catlist = '<select name="cat_id[]" size="5" multiple id="cat_id[]">';
    $catlist .= fillselecteditmultiple(0,$_POST['taglist']);
    $catlist .= '</select>';

    echo json_encode(array("status"=>"success","catlist" => $catlist));
}

fillselecteditmultiple()输出填充的选项,突出显示应该预先选择的选项.它工作正常,因为我在其他页面使用没有问题.为了确保它不是从函数本身抛出的错误,我甚至尝试更改函数输出一个简单的$catlist =’abc’字符串作为响应,仍然是相同的错误.

奇怪的是,Firebug在javascript代码的最后两行抛出一个错误,就像你在附件中看到的那样:

可能导致“?”的原因是什么?出现在我的代码中?

只需检查您的编码.当你在一行的末尾看到“奇怪的”符号时,这可能主要是由编码问题引起的.

另外,常见建议:

When a program doesn’t kNow how to represent a unicode code point,it prints a question mark inside a square (I suppose you have seen this before),or in case it cannot,a simple question mark. An unexpected question mark always makes a developer SUSPECT of encoding. (c) Áxel

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...