0

我正在将一堆内容从 PHP 输出到 JavaScript。从源代码的第 188 行到第 293 行(add 和 addIntroduce 函数),它们在源代码http://example.themobu.com/mychinaroots/中看起来是正确的。但是,我在 jquery.js:2 上得到了 Unexpected token <,因此无法输出任何文本。这是一个示例片段

callback  : function() {
  tempArr = [Number("60"), Number("-108.632812")];
  paths_array[2].temp.push({
    'order'   : 50,
    'location': tempArr
  });
  add(jQuery(this), number += 1, "Cycle", "http://example.themobu.com/mychinaroots/?p=99", "Lorem ipsum Esse et magna ex culpa non qui nisi mollit cillum dolore amet consectetur elit Duis sed fugiat anim occaecat ea minim velit occaecat sed anim pariatur commodo Ut do ea esse dolore Excepteur dolor proident aliqua et irure deserunt magna Duis dolore id nisi sunt sunt esse aliquip consequat cillum pariatur sint magna ...", 60, -108.632812, '', 'http://example.themobu.com/mychinaroots/wp-content/themes/mychinaroots/images/6-default.png');

  tempArr = [Number("-48"), Number("24")];
  paths_array[0].temp.push({
    'order'   : 35,
    'location': tempArr
  });
  paths_array[2].temp.push({
    'order'   : 35,
    'location': tempArr
  });
  add(jQuery(this), number += 1, "Kema", "http://example.themobu.com/mychinaroots/?p=95", "Lorem ipsum Esse et magna ex culpa non qui nisi mollit cillum dolore amet consectetur elit Duis sed fugiat anim occaecat ea minim velit occaecat sed anim pariatur commodo Ut do ea esse dolore Excepteur dolor proident aliqua et irure deserunt magna Duis dolore id nisi sunt sunt esse aliquip consequat cillum pariatur sint magna ...", -48, 24, '', 'http://example.themobu.com/mychinaroots/wp-content/themes/mychinaroots/images/7-default.png');

  tempArr = [Number("-40"), Number("36")];  
  paths_array[2].temp.push({
    'order'   : 25,
    'location': tempArr
  });
  add(jQuery(this), number += 1, "Rad", "http://example.themobu.com/mychinaroots/?p=91", "Lorem ipsum Esse et magna ex culpa non qui nisi mollit cillum dolore amet consectetur elit Duis sed fugiat anim occaecat ea minim velit occaecat sed anim pariatur commodo Ut do ea esse dolore Excepteur dolor proident aliqua et irure deserunt magna Duis dolore id nisi sunt sunt esse aliquip consequat cillum pariatur sint magna ...", -40, 36, '', 'http://example.themobu.com/mychinaroots/wp-content/themes/mychinaroots/images/4-default.png');

  if( jQuery("#main").hasClass("index") ) {
    addIntroduce(jQuery(this), "Welcome to My Blog", "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><br><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><br><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><br><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>", 42, 95 );
  }
} //End Callback
4

1 回答 1

2

问题是调用addIntroduce.

function addIntroduce(jQuerythis, title, content, lati, longi) {
    //var string = JSON.stringify(content);
    console.log(jQuery.parseJSON(content));
}

您期望content是一个 json 字符串(因为您将其解析为一个 json 对象),但您在调用中将一个 html 字符串传递给它addIntroduce(jQuery(this), "Welcome to My Blog", "<p>.....</p>", 42, 95 );

jQuery.parseJSON(content)是引发错误的行。

于 2013-05-31T03:42:08.773 回答