I'm not sure what you really want but try this.
In your JavaScript code, submit the name of your employee via form and perform an ajax call so as to not refresh the page.
Requirements:
jquery framework (widely used js framework that rocks!) - http://jquery.com/download/
jquery ujs so as to handle all ajax calls across your site - https://github.com/rails/jquery-ujs
HTML CODE:
<form action="youraction" method="post" id="form-id" "data-remote" => "true">
<input type="text" name="employee_name"/>
<div id="loader"></div>
<button type="submit">Submit</button>
</form>
<div id="employee-data"></div>
JS CODE:
$(document).ready(function() {
// ajax:before is executed upon submitting your form
// you can insert a loader here or do some validation before sending your ajax call
$('#form-id').on('ajax:before', function() {
// put your code here
$('#loader').show();
});
// ajax:success runs when the server returns a successful call
// display the data returned by your server here
$('#form-id').on('ajax:success', function(event, data) {
// put your code here
// data depends on what kind of data your server responds (json or html format)
$('#employee-data').html(data);
// hide your loader
$('#loader').hide();
});
});
lambing
Junior Poster in Training
76 posts since Feb 2010
Reputation Points: 10
Solved Threads: 15
Skill Endorsements: 0
Question Answered as of 1 Month Ago by
lambing
and
SPeed_FANat1c