javascript — публикация переменных из диалога jQueryUI в PHP с помощью AJAX

Я пытаюсь получить входные данные из входных текстовых полей в диалоговом окне, чтобы использовать их для запроса 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']);

?>

Не знаю, что я делаю неправильно, и извините за мой плохой английский и немецкие слова в коде.
Спасибо за вашу помощь

1

Решение

Используйте приведенные ниже фрагменты кода

         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']
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector