gpt4 book ai didi

php - 如何进行跨域ajax调用

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:41:41 26 4
gpt4 key购买 nike

<分区>

我可以访问一个 API,它是一个 JSP 文件,采用 JSON 格式。我试图从 JSP 页面获取这些数据到 PHP 脚本并处理它们,然后存储在我的 MySQL 服务器中。

JSP页面中的JSON字符串是有效的 我在网上查了几个JSON Formatter和validator。

这是我用来从页面获取 JSON 数据的代码,但每次我的 ajax 调用都会失败。

$('#button').click(function(e){
var url = 'http://xxxxx:8080/StudentAPI/index.jsp';
$.ajax({
url : url,
dataType : 'json',
success : function(response) {
alert('Success');
},
error : function(request, textStatus, errorThrown) {
alert(request+textStatus+errorThrown);
}
});
e.preventDefault();
})

请帮助我,欢迎提出更好的建议。

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