lundi 2 mars 2015

Can't process simple form submitted by jQuery ajax

My form:



<form id="new-protocol-form" method="post" role="form">
<textarea name="text"></textarea>
</form>




My jquery ajax:



$('#submitProtocol').click(
function() {
$.ajax({
type: "POST",
url: "newProtocol.php",
data: $('#new-protocol-form').serialize(),
success: function() { alert{'ok'} },
error: function() { alert('error'); }
});
}
);




My newProtocol.php:



<script>
alert(<?php $_POST('text'); ?>);
</script>




Alert window with 'ok' text triggered by ajax 'success' method is shown, but I can't get alert window with $_POST['text'] value from newProtocol.php file. No error in javascript console.


Aucun commentaire:

Enregistrer un commentaire