I want to display a table using ajax when something is typed in the search box. Before generating any table I am just testing that the ajax call is reached to the controller or not by printing the searched keyword. But it is not working. I think the problem is in the url. But I don't know what could be the solution.
Here is my view:
<input class="form-control" type="text" name="searched_key" id="searched_key">
<div id="live-data"></div>
Here is my ajax:
<script>
$(document).ready(function () {
$("#searched_key").keyup(function () {
var string = $(this).val();
$.ajax({
type: "post",
url: "form_value",
data: {searched_key: $string},
success: function (data) {
$("#live-data").html(data);
}
});
});
});
Here is my controller:
class HomeController extends Controller {
public function get_applicants_info(){
$key_word = $_POST['searched_key'];
echo $key_word; //to test the ajax call
}
}
Here is my routes:
Route::get('/', 'HomeController@index');
Route::post('form','HomeController@store');
Route::post('form_value','HomeController@get_applicants_info');