Calling Javascript function returned from AJAX Response

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • techbytes
    New Member
    • May 2010
    • 36

    #1

    Calling Javascript function returned from AJAX Response

    Hi,

    I have a Page, where i get the response through ajax.In that Page iam calling a javascript function for css purpose of the screen.
    when the response is displayed ,the javascript fn is not invoked.

    help me
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    post your code (in code tags)

    Comment

    • techbytes
      New Member
      • May 2010
      • 36

      #3
      Code:
       
      
      //to display insert page
       function pageDisplay(divid,path)
      {
        alert("divid ...."+divid);
        alert("path ..."+path);
        var pathvalue =document.getElementById(path).value;
        alert("pathvalue ...."+pathvalue);
        searchReq.open('GET','../templates/pagelayout.jsp?path='+pathvalue);
        searchReq.onreadystatechange = function()
                  {
                    pageReply(divid);
                  };
              searchReq.send(null);
      
      }
      
      //------------------------------------------------
      function pageReply(divid)
      {
          alert("Inside the display ..."+divid)
         if(searchReq.readyState == 4)
         {
           var ss = document.getElementById(divid);
           ss.innerHTML = '';
           ss.innerHTML += searchReq.responseText;
           alert("Response ...."+searchReq.responseText);
           ss.style.display = "block";
         }
      
      }
      
      //pagelayout.jsp
      
      <%@page import="java.io.File"%>
      <%@page contentType="text/html" pageEncoding="UTF-8"%>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
         "http://www.w3.org/TR/html4/loose.dtd">
      
      <html>
      
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
              <script language="javascript" src="/ContentManagementSystem/js/ua.js"></script>
              <script language="javascript" src="/ContentManagementSystem/js/ftiens4.js"></script>
            	<link href="/ContentManagementSystem/css/mastersheet.css" rel="stylesheet" type="text/css" media="screen" />
              <link href="/ContentManagementSystem/css/ddsmoothmenu.css" rel="stylesheet" type="text/css" media="screen" />
      	<link href="/ContentManagementSystem/css/stylesheet.css" rel="stylesheet" type="text/css" media="screen" />
      	<link href="/ContentManagementSystem/css/marketing.css" rel="stylesheet" type="text/css" media="screen" />
      	<link href="/ContentManagementSystem/css/dhtmllinkmenu.css" rel="stylesheet" type="text/css" media="screen" />
      	<link href="/ContentManagementSystem/css/staticdiv.css" rel="stylesheet" type="text/css" media="screen" />
      	<link href="/ContentManagementSystem/css/modal.css" rel="stylesheet" type="text/css" media="screen" />
      	<link href="/ContentManagementSystem/css/xCalendar.css" rel="stylesheet" type="text/css" media="screen" />
          </head>
          <!--Calling the Bean Class-->
          <jsp:useBean id="pageLayoutBean" class="com.cmssuite.beans.PageLayoutBean"></jsp:useBean>
      
          <!--      Obtaining the objects based on the needs.    -->
           
              <%
      
              String loadRefresh = "N";
              String xErrorMessage = "";
      
               if (pageLayoutBean.getRequestValue(request, "mode").equalsIgnoreCase("pagelayout")) {
                  System.out.println("before process");
      
                  com.cmsapplication.utilities.ReturnObject rObject = pageLayoutBean.processFunction(request);
                  if (rObject.getReturnCode().equalsIgnoreCase("0"))
                  {
                      System.out.println("Returm Code in pageLayout >>>>"+rObject.getReturnCode());
                    com.cmssuite.application.objects.PageLayout sessionPage = pageLayoutBean.getSessionPageObject(request);
                    System.out.println("Page Name in Session .."+sessionPage.getPageName());
                    response.sendRedirect("../templates/treeview.jsp");
                 //    loadRefresh = "Y";
                  } 
                  else
                  {
                      xErrorMessage = rObject.getReturnMessage();
                      System.out.println("ERROR MESSAGE::::"+xErrorMessage);
                  }
              }
              %>
              <!--script for page refresh -->
       
      <body>
             <form name="pagelayout" id="pagelayout" method="post" action="../templates/pagelayout.jsp?mode=pagelayout">
              <table border="0" cellpadding="3" cellspacing="3" width="100%" style="background-color:#FFFFFF;">
              <tr>
                  <td class="titleHeader" height="25%">&nbsp;HTML Page</td>
              </tr>
                  <td>
                      <table class="table2" width="100%" cellspacing="3" cellpadding="3"  id="GettingStartedPanel">
                              <tr>
                                 <td style="width:50%;" align="right" class="editCellInfoLabel">Page Name :</td>
                                  <td width="50%" align="left" class="editCellInfo">
                                        <div class="ibutton_bg"><input name="PAGE.PAGE_NAME" type="text" value="" id="PAGE.PAGE_NAME" class="ib_regulartextbox" style="text-transform:capitalize;" /></div>
                                  </td>
                              </tr>
      
                              <tr>
                                  <td style="width:50%;" align="right" class="editCellInfoLabel">Folders :</td>
                                  <td width="50%" align="left"  class="editCellInfo">
                                      <div class="ibutton_bg"><input name="PAGE.FOLDER_NAME" type="text" value="<%=request.getParameter("path")%>" id="PAGE.FOLDER_NAME" class="ib_regulartextbox" style="text-transform:capitalize;" /></div>
                                  </td>
                              </tr>
      
                              <tr>
                                  <td style="width:50%;" align="right" class="editCellInfoLabel">Templates :</td>
                                  <td style="width:50%;" align="left" class="editCellInfo">
                                      <select class="selectfield" name="PAGE.TEMPLATE_NAME" id="PAGE.TEMPLATE_NAME" style="width:154px;" onchange="layoutDisplay('template_display',this.options[this.selectedIndex].value)" >
                                          <option value ="">select</option>
                                          <option value ="layout1.jsp">layout1</option>
                                          <option value ="layout2.jsp">layout2</option>
                                          <option value ="layout3.jsp">layout3</option>
                                          <option value ="layout4.jsp">layout4</option>
                                      </select>
                                  </td>
                              </tr>
      
                               <tr>
                                  <td style="width:50%;" align="right" class="editCellInfoLabel">Sample Layout :</td>
                                  <td align="left">
                                  <div class="template_display" align="center" id="template_display">
                                  </div>
                                  <td>
                              </tr>
      
                               <tr><td colspan="4" style="width:100%;" align="left"><img border="0" src="/ContentManagementSystem/images/spacer.gif" width="1" height="5"></td></tr>
                                <tr>
                                  <td style="width:100%;" colspan="4" align="center" valign="middle">
                                          <span class="box">
                                                  <button id="btn_refresh" class="icon" onclick="submitForm('pagelayout');return false;"> <img class="icon" src="/ContentManagementSystem/images/moveright.jpg"/>Next</button>
                                            </span>
                                  </td>
                              </tr>
                      </table>
              </table>
             </form>
          </body>
       </html>

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        what display style has this element before you run the AJAX?

        I don’t see any call to pageDisplay() either.

        PS. it would be more helpful if you posted the client side code (as seen by the browser) as for JavaScript any server-side code is irrelevant

        Comment

        Working...