Question: So if I set this up without ajax, it works fine. As soon as I include ajax, the page loads the url bar with "?search=63105" but nothing displays in the results div

HTML + Jquery

```
<form>
<input type="text" name="search" id="search" placeholder="Search"/>
</form>
<div id="results"></div>

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(function () {
 $("form").on('submit', (function(e){
   var search = $('#search').val();
   var dataString = 'search=' + search;
   e.preventDefault();
   $.ajax({
        type: "POST",
        url: "searchpost.php",
        data: dataString,
        success: function(data) {
            $('#results').html(data);
        }
     });
   });
 });
</script>

```

PHP Page

```
<?php
require_once('../config/db.php');
require_once('../customLIB/pdo_db.php');
require_once('../models/test.php');
$SalesRep = new SalesRep();

if ($_POST['search']) {
 $data = $_POST['search'];
 $rep = $SalesRep->getRep($data);

 if (!empty($rep)) {
    echo $rep->name;
  } else {
    echo "No sales reps found..";
  }
}
?>

```

Again, even when the results should be shown, nothing is showing. The PHP works, this is no problem with that.

Thanks.

Answer: 
The form submit function, you have the line `e.preventDefault()`, however, the function never accepted the event argument `e`.

```
$("form").on('submit', (function(){
    e.preventDefault();
    //...
});

```

Should instead be

```
$("form").on('submit', (function(e) {
    e.preventDefault();
    //...
});

```

Since form submit is never prevented, the form submits as usual and the AJAX call doesn't get fully executed.

EDIT: Additionally, the following lines

```
var search = $('#search').val();
var dataString = 'search=' + search;

```

Should be within the submit function. Only then would it get the value of `#search` during the submission of the search.

EDIT4: Found out that doing `var dataString = 'search=' + search;` works anyway so EDIT2 can be disregarded.

EDIT2: Not too familiar with the PHP side of things, but POST-ing data usually is done with JavaScript objects. Try having `dataString` be

```
var dataString = { search: search };

```

Or better yet, have the form serialize itself

```
var dataString = $('form').serialize();

```

EDIT3: Found an extra parenthesis that might be the cause of the issue.

```
$("form").on('submit', -->(function(e){

```

Final code should be

```
$(function () {
    $("form").on('submit', function (e) {
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: "searchpost.php",
            data: $('form').serialize(),
            success: function (data) {
                $('#results').html(data);
            }
        });
    });
});

```
You are using post method , change the post parameter
data: {'search':search}
And Insted of echo in PHP file, return the value from PHP.