开发者

Ajax pass parameter to page

开发者 https://www.devze.com 2023-03-24 23:51 出处:网络
I have a JSP page that I retrieve with A开发者_C百科JAX. The JSP page has embedded queries that are executed and then rendered as tables. Each execute/render displays the first 100 results.

I have a JSP page that I retrieve with A开发者_C百科JAX. The JSP page has embedded queries that are executed and then rendered as tables. Each execute/render displays the first 100 results.

Is there a way to pass parameters to the queries in the JSP page as a part of my AJAX call? Say, for example, if I wanted to query the database again with a different SQL for the next 100 results?

Thanks.


How are you calling the page with ajax? Like this: http://www.mypage.jsp

Then you could use a querystring -- like this: http://www.mypage.jsp?name=John+Smith

And then in your jsp page, you could have a function like this:

<%
    if (request.getParameter("name") == null) {
        out.println("Oops -- no data found.");
    } else {
        out.println("Howdy <b>"+request.getParameter(i)+"</b>!");
    }
%>
0

精彩评论

暂无评论...
验证码 换一张
取 消