admin管理员组文章数量:1323715
I've the following form which I want to post to page.php and want to get result calculted on page.php and want to show that data in the table boxes using AJAX or JQUERY, is this possible? If yes so let me know please. I don't want to refresh the page as I want to be filled all data on single page and want to display all results on that page(IN table cells as user input data in one table and it will update its response).
<form method = "post" action = "page.php">
<input type = "text" name = "fld1" id = "fld1" />
<input type = "text" name = "result1" id = "result1" value = "value_from_php_page" disabled />
...
</form>
I've the following form which I want to post to page.php and want to get result calculted on page.php and want to show that data in the table boxes using AJAX or JQUERY, is this possible? If yes so let me know please. I don't want to refresh the page as I want to be filled all data on single page and want to display all results on that page(IN table cells as user input data in one table and it will update its response).
<form method = "post" action = "page.php">
<input type = "text" name = "fld1" id = "fld1" />
<input type = "text" name = "result1" id = "result1" value = "value_from_php_page" disabled />
...
</form>
Share
Improve this question
asked Oct 6, 2013 at 2:23
MubinMubin
4,4555 gold badges36 silver badges56 bronze badges
3
- Yes, this is possible. api.jquery./jQuery.post – David Link Commented Oct 6, 2013 at 2:31
- 1 Can you provide me demo pls – Mubin Commented Oct 6, 2013 at 2:53
- 1 @MubinKhalid Have you tried writing some code for it? or at least tried learning it? – sravis Commented Oct 6, 2013 at 2:54
1 Answer
Reset to default 5Yes it is possible. Take a look at this example.
On your page.php
<?php
echo $_POST["fld1"];
?>
On your myForm.html. event.preventDefault() is needed, otherwise submit will perform at default and page will be reload.
<script>
$(function(){
$("#submit").click(function(event){
event.preventDefault();
$.ajax({
type:"post",
url:"page.php"
data:$("#form").serialize(),
success:function(response){
alert(response);
}
});
});
});
</script>
<form id="form" method = "post" action = "page.php">
<input type = "text" name = "fld1" id = "fld1" />
<input type = "text" name = "result1" id = "result1" value = "value_from_php_page" disabled />
<input type="submit" value="Submit" id="submit">
</form>
本文标签: javascriptSending data to php page using ajax and get response and show in fieldsStack Overflow
版权声明:本文标题:javascript - Sending data to php page using ajax and get response and show in fields - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742126101a2421947.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论