ajax - 由于 cors,来自 ajax 的 jsonp 解析错误,但 safari (14) 仍然在错误控制台中显示正确结果
问题描述
使用 jsonp 模式以这种方式绕过 CORS 限制:
function searchPubMed("rs1205") {
return $.ajax({
url: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi',
dataType: 'jsonp',
data: {
db: 'pubmed',
usehistory: 'y',
term: term,
retmode: 'json',
retmax: 10
}
});
}
根据控制台,这成功返回了记录,但有一个解析错误(意外的令牌':'):
{
"header": {
"type": "esearch",
"version": "0.3"
},
"esearchresult": {
"count": "125",
"retmax": "10",
"retstart": "0",
"querykey": "1",
"webenv": "MCID_611764476e03297694413014",
"idlist": [
"34308116",
"33707594",
"33628645",
"33584722",
"33296257",
"32769481",
"32514365",
"32477370",
"32329054",
"31959465"
],
"translationset": [],
"translationstack": [
{
"term": "rs1205[All Fields]",
"field": "All Fields",
"count": "125",
"explode": "N"
},
"GROUP"
],
"querytranslation": "rs1205[All Fields]"
}
}
如何解决解析错误?
解决方案
推荐阅读
- perl - Perl CGI 应用程序疑难解答 - 无法通过包找到对象方法“新”
- sql-server - 尝试插入临时文件时出现 T-SQL 错误
- matlab - matlab直方图,如何设置溢出值并使所有值在一个栏中大于它
- javascript - 更改选择时更改输入值
- azure - Azure Databricks 表未刷新
- java - 使用 GeckoDriver 和 Firefox 出现错误“org.openqa.selenium.WebDriverException: java.net.ConnectException: 无法连接到 localhost/”
- ruby-on-rails - Rails 5 远程形式的间歇性 ActionController::UnknownFormat 错误
- powershell - 解析 Powershell 变量
- javascript - 内容类型八位字节流并在后端处理它
- angular - 等待 http req 单元完成角度(服务)