我想用jQuery发送发布数据到我的发布数据文件处理程序postinfo.php
,但到目前为止我可以做到这一点。发送HTML表单发布数据到Jquery文件?
这里是我的post.php中代码:
<HTML>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<script type="text/javscript">
$('#form_id').on('submit', function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "http://www.vemvo.com/test/postinfo.php",
data: $(this).serialize(),
success: function() {
alert('success');
}
});
});
</script>
<form method="post" id="form_id">
<input type="text" name="ime">
<input type="submit" id="submit" name="submit" value="Send">
</form>
您可以在这里看到的页面:http://www.vemvo.com/test/post.php
这里是我的postinfo.php代码:
<?PHP
$ime = $_POST['ime'];
echo "Your name is $ime";
?>
这里位于postinfo.php - http://www.vemvo.com/test/postinfo.php
那么,我的错误和我如何才能使它工作? 现在它不发送数据,也不给我成功警报。
http://www.johnboy.com/scripts/simple-jquery-form-without-page-refresh/contact.php – Seazoux
裹$( '#form_id')上(” (){...}) – mplungjan