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

Posting Variables from jQueryUI Dialog to PHP with AJAX

我正在尝试从对话框中的输入文本字段中获取输入 window 以将它们用于 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>

这是我的 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);
         },

        function ajax(info){

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

        $_POST['output']