我有一些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>发布于 2008-12-23 09:04:15
success函数接受一个参数,该参数包含获取的数据。因此,在您的示例中:
$(document).ready(
function(){ $.ajax({
type:"GET",
url:"file.php",
data:id,
success:function(txt){
$.prompt( txt,{ opacity: 0.2 });
},
// ... more ...
}
});在jQuery documentation中有更多的例子。
发布于 2012-07-06 06:24:06
jQuery.ajax({
type:"POST",
url:"file.php",
data:"id1="+val1+"&id2="+val2,
success:function(data){
jQuery("#div_id").html(data);
}https://stackoverflow.com/questions/388436
复制相似问题