2

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>
3
  • Yes, this is possible. api.jquery.com/jQuery.post Commented Oct 6, 2013 at 2:31
  • 1
    Can you provide me demo pls Commented Oct 6, 2013 at 2:53
  • 1
    @MubinKhalid Have you tried writing some code for it? or at least tried learning it? Commented Oct 6, 2013 at 2:54

1 Answer 1

5

Yes 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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.