gpt4 book ai didi

javascript - 在 jQuery 中从 AJAX 调用外部 URL

转载 作者:行者123 更新时间:2023-11-30 17:53:36 27 4
gpt4 key购买 nike

<分区>

我需要调用一个返回 JSON 响应的外部 URL(不在我的开发服务器中)。做一些研究我发现 thisthis发布并尝试了几乎每一个,现在我的代码是这样的:

$("#query").on("keyup", function(e) {
if (e.which !== 32) {
var value = $(this).val();
var noWhitespaceValue = value.replace(/\s+/g, '');
var noWhitespaceCount = noWhitespaceValue.length;

if (noWhitespaceCount % 3 === 0) {
var request = $.ajax({
type: 'GET',
data: "text=" + $(this).val(),
url: "http://192.168.0.159:3000/products/search/all",
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown);
request.abort();
}
});
}
}
});

但这行不通,那么实现这一目标的最佳方法是什么?

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