Hallo,
ich verzweifle mal wieder an einem popelligen Ajax-Formular. Ich kapiers einfach nicht.
Hier das Formular. Das spielt eigentlich keine sonderliche Rolle.
meinetest.php. Hier hab ich nur zum testen versucht das $_POST zurück zugeben. Aber mein responsetext ist immer leer.
test.php:
Eigentlich müsste ich doch nach dem Abschicken $_POSt wieder in der Konsole ausgegeben bekommen, oder?
Grüße
ich verzweifle mal wieder an einem popelligen Ajax-Formular. Ich kapiers einfach nicht.
Hier das Formular. Das spielt eigentlich keine sonderliche Rolle.
HTML:
<form method="POST" action="test.php" id="searchForm">
<div class="input-group">
<input id="scanner_input" name="isbn" class="form-control" placeholder="Click the button to scan an EAN..." type="text" value="<?php if(isset($_POST['isbn']) and ($_POST['isbn'] != "")): echo $_POST['isbn']; endif; ?>">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-toggle="modal" data-target="#livestream_scanner">
<i class="fa fa-barcode" style="font-size:1.45em;"></i>
</button>
</span>
</div>
<div class="input-group">
<label class="radio-inline">
<input type="radio" name="show" id="show1" value="1" checked> HTML Ausgabe
</label>
<label class="radio-inline">
<input type="radio" name="show" id="show2" value="2"> Arrays
</label>
<label class="radio-inline">
<input type="radio" name="show" id="show3" value="3"> JSON
</label>
<label class="radio-inline">
<input type="radio" name="show" id="show4" value="4"> Plaintext
</label>
<label class="radio-inline">
<input type="radio" name="show" id="show5" value="5"> 5
</label>
</div>
<input type="submit" name="submit" value="suchen" id="sendForm" class="btn btn-default">
</form>
Javascript:
$('#searchForm').on('submit', function(e){
e.preventDefault();
var form = $(this);
var url = form.attr('action');
var data = form.serialize();
$.ajax({
type: 'POST',
url: url,
dataType: 'json',
data: data,
success: function(response){
console.log(response);
},
error: function(response){
console.log(response);
}
});
});
meinetest.php. Hier hab ich nur zum testen versucht das $_POST zurück zugeben. Aber mein responsetext ist immer leer.
test.php:
PHP:
<?php
$response = $_POST;
return $response;
Grüße