【发布时间】:2011-07-06 05:36:00
【问题描述】:
我正在解析一个JSON文件并将数据添加到HTML下拉列表中,代码如下,
$.getJSON(
"http://mobile.icta.lk/services/railwayservice/getAllLines.php?lang=en&jsoncallback=?",
function(data) {
var $s = $('.txtline').empty();
// the actual contents of this loop will be
// specific to the data
for (var k in data) {
$('<option></option>')
.val(data[k].value)
.text(data[k].text)
.appendTo($s);
}
}
)
我得到一个错误,
Resource interpreted as Script but transferred with MIME type application/json.
getAllLines.php:2Uncaught SyntaxError: Unexpected token :
【问题讨论】:
-
服务器返回的内容是
{还是jQueryLOTSOFNUMBERS({开头的? -
@SalmanA 自己查一下(不要听起来太狡猾)