如何从ajax查询中获取变量

时间:2017-08-01 04:02:08

标签: ajax spring spring-mvc

我想从ajax查询中获取UserID,我想将其保存为搜索用户的变量...我得到了UserId成功,我不知道如何存储它#s值作为变量..我使用Spring框架

    var data = {}
    data["id"] = $(this).attr('data-button');
    anNo=  $(this).attr('data-button');


    $.ajax({
                                type : "post",
                                contentType : "application/json",
                                url : "restservice/impapp/?id=" + anNo,
                                dataType: 'json',
                                success : function(data) {
                                var jString = JSON.stringify(data);
                                var jdata = JSON.parse(jString);
                                deleteRow('dataTbls')
                                        for (var x = 0; x < jdata.impitems.length; x++){
                                var tr = "<tr>";
                                var td1 = "<td>" + jdata.impitems[x].hsCode + "</td>";
                                var td2 = "<td>" + jdata.impitems[x].productName + "</td>";
                                var td3 = "<td>" + jdata.impitems[x].serialNumber + "</td>";
                                var td4 = "<td>" + jdata.impitems[x].modelNumber + "</td>";
                                var td5 = "<td>" + jdata.impitems[x].authorizationNumber + "</td>";
                                var td6 = "<td>" + jdata.impitems[x].authorizationDate + "</td>";
                                var td7 = "<td>" + jdata.impitems[x].yearofManufacture + "</td>";
                                var td8 = "<td>" + jdata.impitems[x].useFor + "</td>";
                                var td9 = "<td>" + jdata.impitems[x].physicalForm + "</td>";
                                var td10 = "<td>" + jdata.impitems[x].type + "</td>";
                                var td11 = "<td>" + jdata.impitems[x].description + "</td>";
                                var td12 = "<td>" + jdata.impitems[x].uom + "</td>";
                                var td13 = "<td>" + jdata.impitems[x].qty + "</td>";
                                var td14 = "<td>" + jdata.impitems[x].uoc + "</td>";
                                var td15 = "<td>" + jdata.impitems[x].value + "</td></tr>";
                                $("#dataTbls").append(tr + td1 + td2 + td3 + td4 + td5 + td6 + td7 + td8 + td9 + td10 + td11 + td12 + td13 + td14 + td15);
                                              }



$('#appcategory').val(jdata.appcategory);
                                                $('#userName').val(jdata.userId);

                                            },

                                                error : function(e) {
                                        alert('Error Occurred!!!!!!!!!!!!!');
                                console.log("ERROR: ", e);
                                            }
                                            });

我的ajax查询工作正常... userID成功返回到userName textFeild ...我想将其存储为变量以便调用用户

<sec:authorize access="hasRole('ADMIN') or hasRole('CHA')">
                                        <td><a href="<c:url value='/view-user-' />" class="btn btn-success pull-right">EXPORTER</a></td>

我想存储像这样的用户ID ......

<c:url value='/view-user-'{userID}/>"

请帮帮我

0 个答案:

没有答案