PDA

View Full Version : ajax response with javascript is not correctly loaded into a panel



dev1751
6 Oct 2009, 2:51 AM
Hi,

The ajax response i receive from my servlet has both html and javascript(both <script>some javascript</script> format and <script src=someURL> format) content in it. I neet to update a panel with the response. when i am using

panel.getEl().update(response,true);

the javascript content in the response is not getting executed. can anyone please help me with this issue?

Thanks,
deepak

The ajax response i receive is
------------------------

<html>
<head>
<link href="resources/styles/style.css" rel="stylesheet" type="text/css"/>
<meta content="no-cache" http-equiv="Cache-Control"/>
<meta content="no-cache" http-equiv="Pragma"/>
</head>

<body bgcolor="white" >

<H1>JSF Faces</H1>

<form id="form" name="form" method="post" action="/sm/js/test_ilog.faces" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="form" value="form" />
<div id="example7_div" style="width:740;height:550; z-index:0"><input type="hidden" id="example7_state" name="example7_state" /><script type="text/javascript">
if(typeof(IlvConstants)=='undefined'){IlvConstants={};}
IlvConstants.contextPath='/sm/_contr?facesService=forward&facesData=res&v=8.6.0.0&res=$res$/';
IlvConstants.ilvImagePath=IlvConstants.contextPath+'jviews/images/';

</script><script type="text/javascript">
if(typeof(IlvFrameworkConstants)=='undefined'){IlvFrameworkConstants={};}
IlvFrameworkConstants.basePath='/sm/_contr?facesService=forward&facesData=res&v=8.6.0.0&res=$res$/jviews/images/';
IlvFrameworkConstants.frameworkPath='/sm/_contr?facesService=forward&facesData=res&v=8.6.0.0&res=$res$/jviews/framework/images/';

</script><script type="text/javascript" src="/sm/_contr?facesService=forward&amp;facesData=res&amp;type=text/javascript&amp;v=8.6.0.0&amp;res=$res$/core.js"> </script><script type="text/javascript" src="/sm/_contr?facesService=forward&amp;facesData=res&amp;type=text/javascript&amp;v=8.6.0.0&amp;res=$res$/framework.js"> </script><script type="text/javascript" src="/sm/_contr?facesService=forward&amp;facesData=res&amp;type=text/javascript&amp;v=8.6.0.0&amp;res=$res$/tgo.js"> </script><div id="example7_ph" style="position:relative;width:100%;height:100%"></div><script type="text/javascript">
IlvObject.disposeByClientId('example7');
example7 = new IltNetworkViewProxy('example7', 'example7_div', '#{defContext}', -1, -1);

</script><script type="text/javascript">
example7.setAbsoluteId(':form:example7');
example7.setImageFormat('PNG');
example7.setServletURL('/sm/_contr');
example7.setServletClass('ilog.tgo.faces.network.dhtml.servlet.IltFacesNetworkServlet');
example7.toHTML();
IlvUtil.addOnLoad(function() {IlvFacesProxy.onload(example7);});
IlvUtil.addOnLoad(function() {IlvSizedViewProxy.onload(example7);});
IlvBodyEventManager.addOnEvent('resize', 'IlvSizedViewProxy.onresize(example7)');

</script></div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="H4sIAAAAAAAAAFvzloG1hIHDMDXZMjnZyKIAADZTRnYQAAAA" />

</form>

</body>
</html>
---------------------

Condor
6 Oct 2009, 3:09 AM
I assume you meant:

panel.getEl().update(response.responseText, true);

Note: Element.update is only meant to load HTML fragments (so no HTML and HEAD tags, no stylesheets and no external script tags).

If you want to keep loading this kind of pages then you should switch to IFRAMEs (try the ManagedIframe user extension).

dev1751
6 Oct 2009, 4:19 AM
will look into managedIframe. thanks for your help.