开发者

passing values from javascript to jsp using jquery

I have a jsp page that submits a form asynchronously using jQuery.ajax(). After successful submission the server returns a json object . Now what I need to do is open a dialog box and display the values in the columns in a table.

I have a div in my jsp representing my dialog box. Now What I am not able to achieve over here is that I am not able to somehow set these column values from the javascript.

I tried adding a hidden variable in the jsp for each column and then setting this variable in the js but it didn't work.

jquery("#data").val(开发者_运维知识库"test")

my html code

Success!!: val val1   val2Ticket Created:  

Now over here I need to populate the table column values and the values after success! with the json object that i retrieve from the json object returned by the ajax request. I have verified that the data is correctly retrieved. Any solutions would be highly appreciated.


I'm not using json objects as such but here is how I do a partial postback in jsp.

JavaScript

var data = {"Ns":Ns, queryString: $('#hdnQueryString').val()};
var success = successSelectSortOrder;
var errorFunction = genericError;
genericPostback("post", hostPath + "ctrlSort.jsp", data,success,errorFunction);

function genericPostback(postbackType,url, data,success,errFunction)
        {
            $.ajax(
                {

                    type : "post",
                    url  : url,
                    data : data,
                    success:success,
                    error :errFunction
                }
            )
        }

        function successSelectSortOrder(msg)
        {
          //do something with the msg here.  
          //generally i have returned html and if not then xml
          //i use jquery to pull it apart from here
        }

Then my jsp page;

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
    out.print("My returned html or data here");
%>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜