需要帮助发现我的语法错误

时间:2014-01-13 18:05:38

标签: javascript syntax

我在某处遇到语法问题但由于我不是javascript开发人员而无法发现它。有眼睛好的人可以指出问题吗?

$.ajax(
    {
        type: 'GET',
        url: / + 'modules/blocklayered/blocklayered-ajax-back.php',

未捕获的SyntaxError:意外的标记ILLEGAL

        data: (all ? '' : $('input[name="categoryBox[]"]').serialize()+'&')+(id_layered_filter ? 'id_layered_filter='+parseInt(id_layered_filter)+'' : ''),
        success: function(result) {

2 个答案:

答案 0 :(得分:2)

语法错误就在这一行......

url: / +     'modules/blocklayered/blocklayered-ajax-back.php',

/放错了位置,应该是......

url: '/modules/blocklayered/blocklayered-ajax-back.php',

答案 1 :(得分:1)

您的url:参数中有拼写错误:

$.ajax({
    type: 'GET',
    url: / +     'modules/blocklayered/blocklayered-ajax-back.php',
      // ^^ here
    data: (all ? '' :     $('input[name="categoryBox[]"]').serialize()+'&')+(id_layered_filter ?    'id_layered_filter='+parseInt(id_layered_filter)+'' : ''),
    success: function(result) {

正确的代码应该是:

$.ajax({
    type: 'GET',
    url: '/modules/blocklayered/blocklayered-ajax-back.php',
    data: (all ? '' :     $('input[name="categoryBox[]"]').serialize()+'&')+(id_layered_filter ?    'id_layered_filter='+parseInt(id_layered_filter)+'' : ''),
    success: function(result) {