Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Refresh page using ajax

Posted on 2008-10-09
9
Medium Priority
?
2,172 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
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
Industry Leaders: 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses

972 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