有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java编辑编辑器仅通过ajax调用加载一次内容

我通过数据库获取问题的值,我想编辑和更新问题的值。问题标题必须在newEdit或fckeditor中打开。由于所有值均来自数据库,但nicEdit仅加载第一次单击的问题标题的值,如果在此之后单击某个问题进行编辑,则不会加载该特定问题的值,它会显示以前加载的问题的值。我需要你的建议来加载每个问题的数据

加上你的评价。jsp

<script type="text/javascript" src="ckeditor-small/nicEdit.js"></script>
<script type="text/javascript">

            //Get the HTTP Object
            function getHTTPObjectForBrowser(){
                    if (window.ActiveXObject)
                        return new ActiveXObject("Microsoft.XMLHTTP");
                    else if (window.XMLHttpRequest) return new XMLHttpRequest();
                    else {
                        alert("Browser does not support AJAX...........");
                    return null;
                }
            }

            function showQuestionList(e){
                httpObject = getHTTPObjectForBrowser();
                if (httpObject != null) {
                    httpObject.open("GET", "getAdminQuestion.action?sectionId="+e, true);
                httpObject.send(null);
                httpObject.onreadystatechange = showQuestionListResponse;
                }
            }
            function showQuestionListResponse(){
                if(httpObject.readyState == 4){
                    var res = httpObject.responseText;

                    jsonObj = JSON.parse(res);

                     var n = jsonObj.length;

                       $('#dyntable tr:not(:first)').remove();

                       for(i=0;i<n;i++){
                           var row = '<tr>';
                           var col = '';
                           col += '<td>'+(i+1)+ '</td>';
                           col += '<td>'+jsonObj[i].questionTitle+ '</td>';
                          /*  col += '<td>'+jsonObj[i].questionContent+ '</td>'; */
                           col += '<td><a href="#myModal" onclick="editQuestion('+jsonObj[i].questionId+')" data-toggle="modal" class="editbutton">Edit</a> &nbsp;&nbsp;| &nbsp;<a class="btn confirmbutton_department" href="deleteQuestionAdmin.action?questionId='+jsonObj[i].questionId+'"> <small>Delete</small> </a></td>';
                           row = row + col + '</tr>';
                           $('#dyntable').append(row);
                      }

                }
            }

            function editQuestion(e){

                httpObject = getHTTPObjectForBrowser();
                if (httpObject != null) {
                    httpObject.open("GET", "editQuestionAdmin.action?questionId="+e, true);
                httpObject.send(null);
                httpObject.onreadystatechange = showQuestionEditResponse;
                }
            }
            function showQuestionEditResponse(){
                if(httpObject.readyState == 4){
                    var res = httpObject.responseText;
                    jsonObj = JSON.parse(res);
                    document.getElementById("editQuestionContent").value = "";
                    document.getElementById("editQuestionTitle").value=jsonObj.questionTitle;
                    document.getElementById("editQuestionContent").value=jsonObj.questionContent;
                    document.getElementById("QuestionEditId").value=jsonObj.questionId;
                    new nicEditor().panelInstance('editQuestionContent');
                    /* new nicEditor({value : jsonObj.questionContent}).panelInstance('editQuestionContent'); */
                }
            }
    </script>


    <form method="post" action="updateQuestionAdmin.action">
                   <div style="width:100%;">
                             <table class="section_table">
                                  <tr>
                                   <td>
                                    <div style="float:left; margin-top:3px;"><label>Question</label></div><div style="float:left;width: 90%;">&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="text" id="editQuestionTitle" name="questionTitle" class="input-large" value="1" style="width:90%;"></div>
                                   </td>
                                  </tr>
                                  <tr>
                                   <td>
                                    <label>Question Heading</label>

                                            <textarea id="editQuestionContent" style="width:650px; height:200px" name="questionContent"></textarea>
                                   </td>
                                  </tr>
                                 </table>
                    </div>
                    <div class="modal-footer">
                   <input type="hidden" id="QuestionEditId" name="questionId" />
                    <button class="btn btn-primary" type="submit">Save</button>

                    <button data-dismiss="modal" class="btn">Close</button>

      </div>
      </form>

共 (0) 个答案