gpt4 book ai didi

javascript - JSONP Ajax 语法

转载 作者:行者123 更新时间:2023-11-28 08:04:31 26 4
gpt4 key购买 nike

我正在尝试使用 JSONP 端点提供的国家/地区代码来提醒我网页的访问者。但是,我似乎无法让这个工作!网络上的所有答案似乎都令人困惑!

从端点返回以下内容:

{
"pcCartCt": 0,
"pcCountryCode": "au",
"pcCountrySite": "WWW",
"pcExpDomCt": 0,
"pcFirstName": "",
"pcIsCdc": false,
"pcIsDiscount": false,
"pcIsGdEmployee": false,
"pcIsTrusted": false,
"pcLanguageCookie": "en-us",
"pcModalData": "",
"pcRepEmail": "",
"pcRepExt": "",
"pcRepName": "",
"pcSelectedCurrFullDesc": "United States Dollar $ (Transactional)",
"pcSelectedCurrType": "USD",
"pcSetLanguageLogo": true,
"pcShopperId": ""
}

为了让它工作,我首先需要指定“myprogid”的 prog_id 和一个回调函数。在回调中,我需要一条包含 pcCountryCode 的警报消息。

我该怎么做?

最佳答案

端点应返回:

myprogid({
"pcCartCt": 0,
"pcCountryCode": "au",
"pcCountrySite": "WWW",
"pcExpDomCt": 0,
"pcFirstName": "",
"pcIsCdc": false,
"pcIsDiscount": false,
"pcIsGdEmployee": false,
"pcIsTrusted": false,
"pcLanguageCookie": "en-us",
"pcModalData": "",
"pcRepEmail": "",
"pcRepExt": "",
"pcRepName": "",
"pcSelectedCurrFullDesc": "United States Dollar $ (Transactional)",
"pcSelectedCurrType": "USD",
"pcSetLanguageLogo": true,
"pcShopperId": ""
});

我不明白你关于解析多个参数的问题。 JSONP 仅需要一个特殊参数:callback=myprogid。该参数应用作响应开头的函数名称。

关于javascript - JSONP Ajax 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24954765/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com