I am using Wordpress, and here is my html code:
<input class="form-control text-right" name="majorhead" required="" type="number" id="majorhead"/>
<div class="result_majorhead"></div>
JS code:
<script>
jQuery("#majorhead").on("keyup",function(){
jQuery.get(ajaxurl,{'action': 'majorhead'},
function (msg) { jQuery(".result_majorhead").html(msg);
});
});
</script>
Here is my code in function.php
add_action('wp_ajax_nopriv_majorhead', 'majorhead_function');
add_action('wp_ajax_majorhead', 'majorhead_function');
function majorhead_function(){
echo 'hello';
exit();
}
For now I am able to display a simple message "Hello" in the same web page whatever I type in the input box. Now I want to display the exact value from the input-text in the display message while typing.
for example: if I type 1, it should display 1 and If I type another another 2 then it should display 12.