gpt4 book ai didi

jquery - 如何将参数传递给 $.ajax()?

转载 作者:行者123 更新时间:2023-12-01 03:53:17 24 4
gpt4 key购买 nike

如何将数据传递给 $.ajax() 调用?我想传递一个 GUID(字符串),在另一种情况下,传递一个包含整数和字符串的数组。

下面的代码工作正常,但我需要传递一些参数进行处理。谢谢!

function btnAdd_onclick() {
$.ajax({
"url": "Add.aspx",
"type": "get",
"success": function (response) {
alert(response);
$("body").append(response);

},
"error": function (response) {
alert("Error: " + response);
}
})
}

最佳答案

您使用 data选项哈希中的参数:

Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).

例如:

$.ajax({
url: '/pancakes/house',
data: { 'where': [ 'is' ] },
// ...
});

关于jquery - 如何将参数传递给 $.ajax()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5759677/

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