Open In App

How to display search result of another page on same page using ajax in JSP?

In this example, we are creating a search bar to display the result on the same page in using ajax in JSP. AJAX stands for Asynchronous JavaScript and XML. Where Ajax is mainly used for Displaying another web page content on the same web page without refreshment of the page. You can read more about ajax technology here.

Approach:
We use the JQuery ready function in order to make sure that our JavaScript does not execute until the page has loaded. Inside the ready function,
we perform a simple use click event with id="#sub" it is the id of the submit bottom on which the action should be performed.






var fn=$("#user_input").val();
$.post("SearchResult.jsp", {n3:fn}, function(data){    
$("#msg").html(data); 
});

In the above code, the

Example:



Output
Before:


After:


Article Tags :