Solved

Refresh page using ajax

Posted on 2008-10-09
9
2,150 Views
Last Modified: 2012-05-05
Dear all,

I have a qn on how I can set it to refresh the page. Ajax doesn't do the refresh and awaits it to load. That's what I want.

However, on the main page, I have an iframe containing a page called pms_list.asp.
Upon clicking the item name in the list, another window will show up in this popup window page called maint_main.asp. If i want to submit a new record to the list, I will have to click a button on maint_main.asp and redirect to maint_new.asp.

Now if i submit maint_new.asp with the records inserted, how do I refresh the pms_list.asp which is not the parent page at all?

Anyone can help me with this asap?

0
Comment
Question by:Yannie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 22682473
The script to refresh the parent of the iframe is this:

 onClick="opener.parent.location.reload(true);"

But that will not help because the onClick will do the refresh imideately on link click not after the update was done on server side.
So your response to the link click should contain the refresh() call like this:
<script>opener.parent.location.reload(true);</script>

Send that snippet after update on server side to the popup and the iframe container page will be reloaded.


0
 
LVL 14

Expert Comment

by:ziffgone
ID: 22682728
Actually, it should be this:

<script type="text/javascript">
window.opener.frames['PMS_LIST_IFRAME_NAME_HERE'].location.reload(true);
</script>

Output the above script from the page called from your AJAX that updates the list database.

Regards...
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 22684505

Please remember that pasting responseText into a div using innerHTML will NOT execute any script.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Yannie
ID: 22699806
Actually

<script>opener.parent.location.reload(true);</script>

refreshes but i will have to wait for th page to refresh done.
I tot Ajax refreshes it alot faster and doesnt show obvious refresh in the background
0
 

Author Comment

by:Yannie
ID: 22699809
Actually

<script>opener.parent.location.reload(true);</script>

refreshes but i will have to wait for th page to refresh done.
I tot Ajax refreshes it alot faster and doesnt show obvious refresh in the background
0
 
LVL 14

Accepted Solution

by:
ziffgone earned 500 total points
ID: 22700119
Yannie,

Instead of using an iframe, use a DIV element, (If you want it to act like an iframe, set the CSS overflow to auto and set your maximum height and width. You can then instantly refresh this content in the DIV with AJAX.:

<div id="pms_list" style="overflow:auto;width:500px;height:300px;">
<!--#include file="pms_list.asp"-->
</div>

Then update the DIV with your AJAX when your button is clicked. Example:

if(xmlHttp.readyState==4) {
      document.getElementById('pms_list").innerHTML=xmlHttp.responseText;
}

Hope this makes sense.

Regards...
0
 

Author Comment

by:Yannie
ID: 23390158
OK thank you very much. Managed to get it solved in my own...thank you..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question