gpt4 book ai didi

jQuery Ajax : return value to caller?

转载 作者:行者123 更新时间:2023-12-01 00:42:06 27 4
gpt4 key购买 nike

我有一些 jQuery 代码。我调用了一个 Ajax 函数文件 file.php,它有一些字段,例如:

<input type="radio" value="plz">Milk</input>.

我会再次分配给 jQuery 函数吗?如果是这样,我该怎么做?我附上了一个示例文件:

<html>
<head>
<LINK REL=StyleSheet HREF="examples.css" TITLE="Contemporary" TYPE="text/css">
<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery-impromptu.1.6.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$.ajax({
type:"GET",
url:"file.php",
data:id,
success:function(){
var txt=id;
$.prompt( txt,{ opacity: 0.2 });
},
error:function(){
window.location("ERRoR");
}
});
});
</script>

<body>
</body>
</html>

最佳答案

success 函数采用一个参数,其中包含获取的数据。所以在你的例子中:

$(document).ready(
function(){ $.ajax({
type:"GET",
url:"file.php",
data:id,
success:function(txt){
$.prompt( txt,{ opacity: 0.2 });
},
// ... more ...
}
});

更多示例位于 jQuery documentation .

关于jQuery Ajax : return value to caller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/388436/

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