это простой пример, как отправить форму с помощью формы плагинов Jquery и извлечения данных с использованием формата HTML HTML кодотправить форму с помощью JQuery Ajax Form Plugin и php?
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
// prepare the form when the DOM is ready
$(document).ready(function() {
// bind form using ajaxForm
$('#htmlForm').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#htmlExampleTarget',
// success identifies the function to invoke when the server response
// has been received; here we apply a fade-in effect to the new content
success: function() {
$('#htmlExampleTarget').fadeIn('slow');
}
});
});
</script>
</head>
<body>
<form id="htmlForm" action="post.php" method="post">
Message: <input type="text" name="message" value="Hello HTML" />
<input type="submit" value="Echo as HTML" />
</form>
<div id="htmlExampleTarget"></div>
</body>
</html>
PHP код
<?php
echo '<div style="background-color:#ffa; padding:20px">' . $_POST['message'] . '</div>';
?>
это просто отлично работает , что мне нужно знаю, что если мне нужно Сериализовать поля формы, чтобы как передать этот параметр через функцию JS , также я хочу показать загружаемое сообщение при обработке формы , как я должен это сделать tha nk you
Для загрузки сообщения вы можете использовать функцию beforeSend таким образом: beforeSend: функция() { $ ("# htmlExampleTarget") HTML ('Загрузка ...'); \t \t}, – Kamal