469,277 Members | 1,916 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

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
Sep 8 '11 #1
3 1728
Dormilich
8,651 Expert Mod 8TB
post your code (in code tags)
Sep 8 '11 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. //to display insert page
  4.  function pageDisplay(divid,path)
  5. {
  6.   alert("divid ...."+divid);
  7.   alert("path ..."+path);
  8.   var pathvalue =document.getElementById(path).value;
  9.   alert("pathvalue ...."+pathvalue);
  10.   searchReq.open('GET','../templates/pagelayout.jsp?path='+pathvalue);
  11.   searchReq.onreadystatechange = function()
  12.             {
  13.               pageReply(divid);
  14.             };
  15.         searchReq.send(null);
  16.  
  17. }
  18.  
  19. //------------------------------------------------
  20. function pageReply(divid)
  21. {
  22.     alert("Inside the display ..."+divid)
  23.    if(searchReq.readyState == 4)
  24.    {
  25.      var ss = document.getElementById(divid);
  26.      ss.innerHTML = '';
  27.      ss.innerHTML += searchReq.responseText;
  28.      alert("Response ...."+searchReq.responseText);
  29.      ss.style.display = "block";
  30.    }
  31.  
  32. }
  33.  
  34. //pagelayout.jsp
  35.  
  36. <%@page import="java.io.File"%>
  37. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  38. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  39.    "http://www.w3.org/TR/html4/loose.dtd">
  40.  
  41. <html>
  42.  
  43.     <head>
  44.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  45.         <script language="javascript" src="/ContentManagementSystem/js/ua.js"></script>
  46.         <script language="javascript" src="/ContentManagementSystem/js/ftiens4.js"></script>
  47.           <link href="/ContentManagementSystem/css/mastersheet.css" rel="stylesheet" type="text/css" media="screen" />
  48.         <link href="/ContentManagementSystem/css/ddsmoothmenu.css" rel="stylesheet" type="text/css" media="screen" />
  49.     <link href="/ContentManagementSystem/css/stylesheet.css" rel="stylesheet" type="text/css" media="screen" />
  50.     <link href="/ContentManagementSystem/css/marketing.css" rel="stylesheet" type="text/css" media="screen" />
  51.     <link href="/ContentManagementSystem/css/dhtmllinkmenu.css" rel="stylesheet" type="text/css" media="screen" />
  52.     <link href="/ContentManagementSystem/css/staticdiv.css" rel="stylesheet" type="text/css" media="screen" />
  53.     <link href="/ContentManagementSystem/css/modal.css" rel="stylesheet" type="text/css" media="screen" />
  54.     <link href="/ContentManagementSystem/css/xCalendar.css" rel="stylesheet" type="text/css" media="screen" />
  55.     </head>
  56.     <!--Calling the Bean Class-->
  57.     <jsp:useBean id="pageLayoutBean" class="com.cmssuite.beans.PageLayoutBean"></jsp:useBean>
  58.  
  59.     <!--      Obtaining the objects based on the needs.    -->
  60.  
  61.         <%
  62.  
  63.         String loadRefresh = "N";
  64.         String xErrorMessage = "";
  65.  
  66.          if (pageLayoutBean.getRequestValue(request, "mode").equalsIgnoreCase("pagelayout")) {
  67.             System.out.println("before process");
  68.  
  69.             com.cmsapplication.utilities.ReturnObject rObject = pageLayoutBean.processFunction(request);
  70.             if (rObject.getReturnCode().equalsIgnoreCase("0"))
  71.             {
  72.                 System.out.println("Returm Code in pageLayout >>>>"+rObject.getReturnCode());
  73.               com.cmssuite.application.objects.PageLayout sessionPage = pageLayoutBean.getSessionPageObject(request);
  74.               System.out.println("Page Name in Session .."+sessionPage.getPageName());
  75.               response.sendRedirect("../templates/treeview.jsp");
  76.            //    loadRefresh = "Y";
  77.             } 
  78.             else
  79.             {
  80.                 xErrorMessage = rObject.getReturnMessage();
  81.                 System.out.println("ERROR MESSAGE::::"+xErrorMessage);
  82.             }
  83.         }
  84.         %>
  85.         <!--script for page refresh -->
  86.  
  87. <body>
  88.        <form name="pagelayout" id="pagelayout" method="post" action="../templates/pagelayout.jsp?mode=pagelayout">
  89.         <table border="0" cellpadding="3" cellspacing="3" width="100%" style="background-color:#FFFFFF;">
  90.         <tr>
  91.             <td class="titleHeader" height="25%">&nbsp;HTML Page</td>
  92.         </tr>
  93.             <td>
  94.                 <table class="table2" width="100%" cellspacing="3" cellpadding="3"  id="GettingStartedPanel">
  95.                         <tr>
  96.                            <td style="width:50%;" align="right" class="editCellInfoLabel">Page Name :</td>
  97.                             <td width="50%" align="left" class="editCellInfo">
  98.                                   <div class="ibutton_bg"><input name="PAGE.PAGE_NAME" type="text" value="" id="PAGE.PAGE_NAME" class="ib_regulartextbox" style="text-transform:capitalize;" /></div>
  99.                             </td>
  100.                         </tr>
  101.  
  102.                         <tr>
  103.                             <td style="width:50%;" align="right" class="editCellInfoLabel">Folders :</td>
  104.                             <td width="50%" align="left"  class="editCellInfo">
  105.                                 <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>
  106.                             </td>
  107.                         </tr>
  108.  
  109.                         <tr>
  110.                             <td style="width:50%;" align="right" class="editCellInfoLabel">Templates :</td>
  111.                             <td style="width:50%;" align="left" class="editCellInfo">
  112.                                 <select class="selectfield" name="PAGE.TEMPLATE_NAME" id="PAGE.TEMPLATE_NAME" style="width:154px;" onchange="layoutDisplay('template_display',this.options[this.selectedIndex].value)" >
  113.                                     <option value ="">select</option>
  114.                                     <option value ="layout1.jsp">layout1</option>
  115.                                     <option value ="layout2.jsp">layout2</option>
  116.                                     <option value ="layout3.jsp">layout3</option>
  117.                                     <option value ="layout4.jsp">layout4</option>
  118.                                 </select>
  119.                             </td>
  120.                         </tr>
  121.  
  122.                          <tr>
  123.                             <td style="width:50%;" align="right" class="editCellInfoLabel">Sample Layout :</td>
  124.                             <td align="left">
  125.                             <div class="template_display" align="center" id="template_display">
  126.                             </div>
  127.                             <td>
  128.                         </tr>
  129.  
  130.                          <tr><td colspan="4" style="width:100%;" align="left"><img border="0" src="/ContentManagementSystem/images/spacer.gif" width="1" height="5"></td></tr>
  131.                           <tr>
  132.                             <td style="width:100%;" colspan="4" align="center" valign="middle">
  133.                                     <span class="box">
  134.                                             <button id="btn_refresh" class="icon" onclick="submitForm('pagelayout');return false;"> <img class="icon" src="/ContentManagementSystem/images/moveright.jpg"/>Next</button>
  135.                                       </span>
  136.                             </td>
  137.                         </tr>
  138.                 </table>
  139.         </table>
  140.        </form>
  141.     </body>
  142.  </html>
  143.  
  144.  
  145.  
  146.  
  147.  
Sep 8 '11 #3
Dormilich
8,651 Expert Mod 8TB
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
Sep 8 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Krishna | last post: by
6 posts views Thread by szabelin | last post: by
4 posts views Thread by Martin Feuersteiner | last post: by
1 post views Thread by Larry | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.