Javascript 使用AJAX将变量从jQueryUI对话框发布到PHP

Javascript 使用AJAX将变量从jQueryUI对话框发布到PHP,javascript,php,ajax,jquery-ui,dialog,Javascript,Php,Ajax,Jquery Ui,Dialog,我试图从对话框窗口中的输入文本字段中获取输入,以便将它们用于SQL查询 我的问题是我不能在PHP中使用数组。我没有收到错误或成功的消息。 在Firefox的网络日志中,我可以看到具有正确值的Post方法 以下是我的js代码片段: <script> // open popup window "dialog" $(function() { $( "#dialog" ).dialog({ autoOpen: f

我试图从对话框窗口中的输入文本字段中获取输入,以便将它们用于SQL查询

我的问题是我不能在PHP中使用数组。我没有收到错误或成功的消息。 在Firefox的网络日志中,我可以看到具有正确值的Post方法

以下是我的js代码片段:

<script>
    // open popup window "dialog"
        $(function() {
            $( "#dialog" ).dialog({
                autoOpen: false ,
                width: 1000,
                buttons: {
                    "Quelle hinzufügen": function() {                           

                        var out = [document.getElementById("titelin"),document.getElementById("autorin"),document.getElementById("tagsin"),document.getElementById("linkin")];
                        var outv = [out[0].value,out[1].value,out[2].value,out[3].value];                       
                        ajax(outv);
                    },
                Abbrechen: function() {
                  $( this ).dialog( "close" );
                }   
                }   
            }); 
            $( "#opener" ).click(function(e) {
                 e.preventDefault();
                $( "#dialog" ).dialog("open");
            });
        });
        // posting to PHP
        function ajax(outv){

            $.ajax({
                type:"POST",
                url:"quellenverzeichnis.php",
                data: {output: outv},               
                sucess: function(){
                    alert("works");
                },
                error:  function(){
                    alert("fail");
                }
            });
        }; 
    </script>

//打开弹出窗口“对话框”
$(函数(){
$(“#对话框”)。对话框({
自动打开:错误,
宽度:1000,
按钮:{
“Quelle hinzufügen”:函数(){
var out=[document.getElementById(“titelin”)、document.getElementById(“autorin”)、document.getElementById(“tagsin”)、document.getElementById(“linkin”);
var outv=[out[0]。值,out[1]。值,out[2]。值,out[3]。值];
ajax(outv);
},
Abbrechen:function(){
$(此).dialog(“关闭”);
}   
}   
}); 
$(“#开启器”)。单击(函数(e){
e、 预防默认值();
$(“对话框”)。对话框(“打开”);
});
});
//发布到PHP
函数ajax(outv){
$.ajax({
类型:“POST”,
url:“quellenverzeichnis.php”,
数据:{output:outv},
suces:function(){
警惕(“工作”);
},
错误:函数(){
警报(“失败”);
}
});
}; 
以下是我的PHP代码:

<?php

if (isset($_POST['output'])){
    hinzufuegen();
};
printf($_POST['output']);

?>

不知道我做错了什么,为我糟糕的英语和代码中的德语单词感到抱歉。
感谢您的帮助

使用下面的代码片段

         buttons: {
              "Quelle hinzufügen": function() {
                 var out = [];
                 out.push(document.getElementById("titelin").value);
                 out.push(document.getElementById("autorin").value);
                 out.push(document.getElementById("tagsin").value);
                 out.push(document.getElementById("linkin").value);
                 ajax(out);
         },


data:{output:bla},
这个bla来自哪里?这就是为什么您的请求会变为空白,因为未定义的
bla
不会发送
output
fieldprintf($_Post['output']);如果错误,则应使用printf($_POST['output']);很抱歉,bla只是一个用字符串而不是数组进行的测试。请输入实际代码,这样我们就不必从不同的方向进行挖掘。谢谢你的帮助,它可以工作……但我的问题是,我希望在网站上打印,但没问题。你试过echo吗?我已经再次更新了代码,请立即尝试此成功消息,不要弹出,但我在php中获得了数组,可以执行sql请求。您的
成功
回调代码中有输入错误,应该是
成功
,请尝试我的新更新代码
        function ajax(info){

            $.ajax({
                type:"POST",
                url:"quellenverzeichnis.php",
                data: {output: info},                
                success: function(data){
                    alert("works"+data);
                },
                error:  function(){
                    alert("fail");
                }
            });
        };
        $_POST['output']