Hi,

For some reason form submit is not working properly while I am using Ajax.

I want the result to be displayed on the same page. I am using Ajax for this, but when I submit the form, only text is being displayed rather than the actual value.

This is the sample code

//THE FORM
<div id="leftcoloumn">
    <form action="javascript:ajaxpage('files/search2.php', 'rightcolumn')" method="POST">
                            Email :<input type="text" name="email" value=""/>
                            <input type="submit" value="Submit">
    </form>
</div>
<div id="rightcolumn">
    <div style="clear: left; margin-bottom: 1em"></div>
</div>
//THE PHP FILE - search2.php
<?php
    $email = $_POST['email'];
    echo "The Email ID is :";
    echo $email;
?>
<html>
<body>
    <h1>Hello World</h1>
</body>
</html>

//Problem - search2.php only displays "The Email ID is :"
//It does not display the actual value entered in the text field i.e $email
When I have only search2.php in the form action field, then it displays $email buit on a separate page.
I want the result to appear on the same page i.e under

<div id="rightcolumn">
        <div style="clear: left; margin-bottom: 1em"></div>
    </div>

$email

$email.val()

Instead of using,

<form action="javascript:ajaxpage('files/search2.php', 'rightcolumn')" method="POST">

why not try using

<form onsubmit="javascript:ajaxpage('files/search2.php', 'rightcolumn')" method="POST">

onsubmit is not working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.