简体   繁体   English

JSONP + SyntaxError:缺少; 在声明之前

[英]JSONP + SyntaxError: missing ; before statement

I've been googling this, found recommendations but I couldn't apply correctly. 我一直在谷歌搜索,发现建议,但我无法正确应用。 I am calling a json API from other domain so i used jsonp. 我从其他域调用json API,所以我使用了jsonp。 Please check my code. 请检查我的代码。

$(document).ready(function () {               
    $("#btnSubmit").click(function () {
        GetParam(function (data) {
            alert(data.toString());
        });
    });
 });

  function GetParam(func) {
      $.getJSON("http://test.com/api/getparams.ashx?callback=?", function (result) {});
  }

It is able to call the API and show the result. 它可以调用API并显示结果。 It's just that there is this semicolon issue. 只是存在这个分号问题。

在此输入图像描述

From what i have researched, they say i should return a jsonp format but how can i do that? 根据我的研究,他们说我应该返回一个jsonp格式,但我该怎么做呢? Note: I don't have access to the source code of the API. 注意:我无权访问API的源代码。

Thanks. 谢谢。

如果你使用jsonp使用$.ajax({dataType: 'jsonp'...});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM