Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqueryajax:向调用者返回值?_Jquery_Ajax_Return Value_Return - Fatal编程技术网

jqueryajax:向调用者返回值?

jqueryajax:向调用者返回值?,jquery,ajax,return-value,return,Jquery,Ajax,Return Value,Return,我有一些jQuery代码。我调用了一个Ajax函数文件file.php,其中包含一些字段,如: <input type="radio" value="plz">Milk</input>. 牛奶。 我将再次分配到jQuery函数中吗?如果是,我该怎么做?我附上了一份样本文件: <html> <head> <LINK REL=StyleSheet HREF="examples.css" TITLE="Contempor

我有一些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>

$(文档).ready(函数(){
$.ajax({
键入:“获取”,
url:“file.php”,
数据:id,
成功:函数(){
var-txt=id;
$.prompt(txt,{opacity:0.2});
},
错误:函数(){
窗口位置(“错误”);
}
});
});

函数
success
接受一个参数,该参数包含获取的数据。在你的例子中:

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

如果我想从php文件返回HTML数据(例如var data=(success results)),更多的例子在.

中。上面的方法也适用吗?
jQuery.ajax({
     type:"POST",
     url:"file.php",
     data:"id1="+val1+"&id2="+val2,
     success:function(data){
       jQuery("#div_id").html(data);
    }