Jquery 语法错误:缺少;关于JSONResponse的before语句

Jquery 语法错误:缺少;关于JSONResponse的before语句,jquery,python,json,ajax,django,Jquery,Python,Json,Ajax,Django,我遇到了这样的错误: SyntaxError: missing ; before statement 我不知道是什么原因导致错误,但我这里有以下代码: (function pollschedule(){ $.ajax({type: "GET", dataType: "jsonp", contentType: "application/json", url: "http://127.0.0.1:8080/get/schedule/1/", success:

我遇到了这样的错误:

SyntaxError: missing ; before statement
我不知道是什么原因导致错误,但我这里有以下代码:

(function pollschedule(){
    $.ajax({type: "GET",
    dataType: "jsonp",
    contentType: "application/json",
    url: "http://127.0.0.1:8080/get/schedule/1/",
    success: function(data){
        console.log(data);
    }, 
    complete: pollschedule, timeout: 5000});
})();
如果您可能需要查看以下内容:

并返回以下内容:

{"schedule": {"CWW": [{"date": "2016-11-11", "time": "17:10:10"}]}}
错误将分号指向响应中“schedule”之后。

不是。您的响应是JSON,但您已经告诉jQuery需要JSONP


要么使响应有效JSONP,要么更新执行检索的代码以期望JSON。(请注意,如果您使用后者,您将遇到跨源问题,除非运行ajax的页面也在
http://127.0.0.1:8080

很好,我错过了那里的数据类型。@T.J.Crowder我将数据类型更改为json,你是对的,我遇到了跨源代码,得到了注意。现在我的问题是为什么它没有显示在模板上?很抱歉要求提供更多信息。@JanWilmar:在本网站上搜索“同源策略”(SOP)和“跨源资源共享”(CORS)以及有关JSONP的更多信息。
{"schedule": {"CWW": [{"date": "2016-11-11", "time": "17:10:10"}]}}