Solved

Refresh page using ajax

Posted on 2008-10-09
9
2,131 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now