I am a noob at ajax, but I think my problem is fairly simple. After I submit my form, I would like to have the server echo back to me. Here is my current code which is not working. I'm fairly certain that the problem is with my ajax, because I know that my values are being placed in dataString.

**HTML**

```
<form method="POST" onSubmit="new_user(this);" >
<input type="submit" value="signed" name="astatus" />
<input type="hidden" value="FaKEIdkEy" name="mark_attend" />
</form>

```

**Javascript**

```
function new_user(form){
    var url = "attendance.php";

    var dataString = "status="+form.astatus.value;
    dataString = dataString+"&id="+form.mark_attend.value;

    $.ajax({  
type: "POST",  
url: url, 
data: dataString,  
success: function(data) {
alert(data);
}
});
}

```

**php** (attendance.php)

```
if(!empty($_POST))
{
echo "response";
}

```

Any Ideas on how to fix?
['https://Stackoverflow.com/questions/18236639', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2406939/']
You should add a `return false;` at the end of the function to prevent the form from submitting.

```
function new_user(form) {
    var url = "attendance.php";

    var dataString = "status="+form.astatus.value+"&id="+form.mark_attend.value;

    $.ajax({  
        type: "POST",  
        url: url, 
        data: dataString,  
        success: function(data) {
            alert(data);
        }
    });

    return false;
}

```
```
You are calling ajax at on submit , so when ajax run after that page is reload so data is vanished. 
<form method="POST"  >
<input type="button" value="signed" name="astatus" onclick="new_user()" />
<input type="hidden" value="FaKEIdkEy" name="mark_attend"  id="mark_attend"/>
</form>

and get the value with jquery 
var fakeidkey=$_('#mark_attend').val();
and then concat it with your varaible .

```