【问题标题】:Error when returning value using JSONP使用 JSONP 返回值时出错
【发布时间】:2012-04-15 16:54:03
【问题描述】:

我在使用 jsonp 到 API HTTPS 网站时遇到问题。 它会在下面返回

response=1&responsetext=SUCCESS&authcode=123456&transactionid=1592337329&avsresponse=&cvvresponse=&orderid=&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=

这是我的代码。

function getJSON() {
    $.ajax({
        type: "POST",
        dataType: 'jsonp',
        data:{},
        jsonp: true,
        jsonpCallback: "callbackName",
        url: 'https://secure.equitycommercegateway.com/api/transact.php?username=test123&password=test1234&ccnumber=4111111111111111&ccexp=1012&amount=10.00&type=sale&product_sku_1=monthly&callbackName=?',
        success: function(msg){
            alert(msg);
        }
    });
}

$(document).ready(function(){
    var callbackName = function(data) {
        //alert(data.listing.id );
    }
    getJSON();
});

它显示了一个控制台错误,读取响应文本时出错.. 并指向“SUCCESS”文本之前的 (=) 符号。

谁能帮帮我?

【问题讨论】:

  • 好吧,response=1&responsetext=SUCCESS... 不是 JSONP。它是一个查询字符串。确保正确处理返回值。
  • 回调函数应该是全局的。否则它无法从注入的脚本中访问。将其附加到窗口对象或在括号外定义。
  • 好吧,我该如何解决这个问题?你有什么想法吗?..

标签: javascript api jquery https jsonp


【解决方案1】:

无法发出 JSONP POST 请求,请参阅此 post

【讨论】:

    猜你喜欢
    • 2011-03-27
    • 2021-07-20
    • 1970-01-01
    • 2012-06-30
    • 2015-08-27
    • 1970-01-01
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    相关资源
    最近更新 更多