473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Javascript popup window question

31
All,

I am using javascript (window.open()) to create a popup to do some processing. This popup is going to create a PDF which can take anywhere from 10 secs to 2 mins (alot of backend SQL calls) and I was hoping to use this popup to show the user that something is going on (animated gif) and give them the ability to use the parent window to do other things in our system (while the popup is creating the PDF on the server).

My problem lies in the fact that while the popup is creating the PDF, the parent window cannot navigate to other pages (until the popup window is done). Is there any way to disassociate the popup window with the parent window so a user will be able to navigate with the parent window while the popup window is processing?

Thx
jonpfl
Jul 17 '08 #1
18 2311
gits
5,390 Expert Mod 4TB
you could send an AJAX-call and just open the window when the server sends the response ... this is done in the onreadystatechange-callback - first just have a look at a basic AJAX-example and ask more questions about it when you have them :)

kind regards
Jul 17 '08 #2
jonpfl
31
I have never used ajax before.

Is there a way to do with just javascript or am I going to have to get ajax?

Thx
jonpfl
Jul 17 '08 #3
gits
5,390 Expert Mod 4TB
AJAX is just javascript ;) ... by making use of the browsers XMLHttpRequest and its asynchronous behaviour ... with that you could achieve what you want ...

kind regards
Jul 17 '08 #4
jonpfl
31
AJAX is just javascript ;) ... by making use of the browsers XMLHttpRequest and its asynchronous behaviour ... with that you could achieve what you want ...

kind regards
Ok, let me get this straight.

If I incorporate Ajax on my child/popup to create the PDF, my user is going to be able to go to the parent window and navigate to another page while the child/popup is awaiting a response from the server?

Sorry if this is a total newbie question but I am new at this.

Thx
jonpfl
Jul 17 '08 #5
gits
5,390 Expert Mod 4TB
not exactly ... basicly you start a async XMLHttpRequest and say: open the window when you are ready ... the user may do whatever he wants in the meantime ...
Jul 17 '08 #6
jonpfl
31
not exactly ... basicly you start a async XMLHttpRequest and say: open the window when you are ready ... the user may do whatever he wants in the meantime ...
Now that you tell me this, I think I might want to do it another way (tell me which ones are feasible)

1) User is on page1.asp and clicks a button to create a PDF. I use javascript to send an async call to the server to start creating the PDF (it is all vbscript with a bunch of stored procs). While the PDF is being created, I assume the user can navigate to page2.asp and do something else, correct? I was thinking that instead of using a popup window when completed, I could just email them the PDF using vbscript on the server. Does this sound doable? I assume I do not actually have to have a callback function, right?

2) If I decide to use a popup window and user makes the request on page1.asp and has now changed to page2.asp, how would I handle that? I assume every possible page the user could navigate to in our internal app, I would have to have that callback function declared in the javascript, right? We currently have an include file called common.asp that I could it in since all our pages include that.

Is there a specific version of Ajax you recommend for ASP? Right now, I am reading up on one called "Sarissa"

Thx
jonpfl
Jul 17 '08 #7
gits
5,390 Expert Mod 4TB
i think your first version sounds quite good ... but to clarify something: the callbackfunction is passed to the requestobject itself ... it mustn't be declared on every page ... and there is nothing like an ajax-version or something similar ... it is just javascript and xml and an instance of the XMLHttpRequest-Object of a browser ... there are just some frameworks out there that encapsulate the usage of all of this ...
Jul 17 '08 #8
jonpfl
31
i think your first version sounds quite good ... but to clarify something: the callbackfunction is passed to the requestobject itself ... it mustn't be declared on every page ... and there is nothing like an ajax-version or something similar ... it is just javascript and xml and an instance of the XMLHttpRequest-Object of a browser ... there are just some frameworks out there that encapsulate the usage of all of this ...
Ok, I put some ajax in my javascript code

Expand|Select|Wrap|Line Numbers
  1.             http_request = new XMLHttpRequest();
  2.             sURL = "ReportHeading=" + frmCreditReport.ReportHeading.value;
  3.             sURL += "&MeetingId=" + frmCreditReport.MeetingId.value;
  4.             http_request.onreadystatechange = jon;
  5.             http_request.open('POST', "popup_pdf.asp?" + sURL, true);
  6.             http_request.send(null);
  7.  
  8. function jon()
  9. {
  10.     if (http_request.readyState == 4)
  11.     { 
  12.         alert(http_request.responseText);
  13.     } 
  14. }
  15.  
And I can see that the PDF is getting created (I save it to a temp directory) but I still have the problem of not being able to navigate to another page. When I try to change to another page, my page waits until the Ajax is complete before continuing.

What am I doing wrong?

Thx
jonpfl
Jul 17 '08 #9
gits
5,390 Expert Mod 4TB
is it a large pdf? ... what if you just alert a string like 'foo'? may be the problem is the transfer of the response data and not the pdf-creation at all? presenting a download-link or send it per mail as you already suggested would workaround that?
Jul 17 '08 #10
jonpfl
31
is it a large pdf? ... what if you just alert a string like 'foo'? may be the problem is the transfer of the response data and not the pdf-creation at all? presenting a download-link or send it per mail as you already suggested would workaround that?
Yes, it is a very large PDF

I cannot email it because I would have the same problem. When I am in the processing of creating it (~ 1 min), I cannot navigate with the calling window to other pages. Is there a way to do that?

IE : I am on an asp page and a user clicks a button to create a PDF. I send that request to the server for prcoessing. This process can take upwards of 2 mins and I want the user to be able to navigate to other pages while the PDF is being created. If I try to navigate away from the page that made the PDF request (in this case, via Ajax), it just hangs until the PDF creation process is completed.

Thx
jonpfl
Jul 17 '08 #11
gits
5,390 Expert Mod 4TB
did you try the 'foo'-alert? ... in your case it seems to be a good idea to start the request, and update the page with a link to the created file at the server in the callback and let the user decide to download it ... this will typically be done with the browsers download-manager ... could that be an option? as i said ... the browser doesn't wait for the request, i guess he waits for the pdf-data transfer ...

kind regards
Jul 18 '08 #12
jonpfl
31
did you try the 'foo'-alert? ... in your case it seems to be a good idea to start the request, and update the page with a link to the created file at the server in the callback and let the user decide to download it ... this will typically be done with the browsers download-manager ... could that be an option? as i said ... the browser doesn't wait for the request, i guess he waits for the pdf-data transfer ...

kind regards
Actually, I changed the callback function to a 'foo'-alert. I now see what is going on. If I start the request and it is processing in the background and I try to go to another website (ie www.google.com), it lets me (and I assume the request to call the callback function is disregarded by the browser). BUT, if I try to navigate inside my webpage using the menu system someone else devised, it does not allow me to change pages.

Any idea why?

Thx
jonpfl
Jul 18 '08 #13
gits
5,390 Expert Mod 4TB
hmmm ... is the page-menu responding in any way? does it reload the window onclick? in case the window is reloaded then i think the current request will be aborted ... do you have a testpage online, so that i could have a deeper look at it?
Jul 18 '08 #14
jonpfl
31
hmmm ... is the page-menu responding in any way? does it reload the window onclick? in case the window is reloaded then i think the current request will be aborted ... do you have a testpage online, so that i could have a deeper look at it?
I wish I had a test page online but this is all internal work at the moment. I do notice that if I am creating a PDF on the server, I can enter an URL for another part of our system w/o using the menus and it works. If I try to navigate with our menus to the same page, it doesn't work.

I have a feeling something in our menuing system is funky and needs to be looked at. I can put the code up here if you want to look at it (I am fairly new at this stuff so alot of it doesnt make sense to me)

Thx for all your help to this point. You have been very helpful!!!
Jul 18 '08 #15
jonpfl
31
hmmm ... is the page-menu responding in any way? does it reload the window onclick? in case the window is reloaded then i think the current request will be aborted ... do you have a testpage online, so that i could have a deeper look at it?
Actually, I looked at the page some more and noticed the menu system is using <a href'=""> all over the place. I tried putting a <a href="">click here</a> on my page and while the PDF was being created, I clicked on the text and the page would not change until the PDF was created. I could manually put the same URL in browser and submit it while the PDF was being created and it worked fine.

Thx
jonpfl
Jul 18 '08 #16
gits
5,390 Expert Mod 4TB
does it work with:

Expand|Select|Wrap|Line Numbers
  1. <span onclick="window.location.href='http://www.google.com'">click me</span>
kind regards
Jul 18 '08 #17
jonpfl
31
does it work with:

Expand|Select|Wrap|Line Numbers
  1. <span onclick="window.location.href='http://www.google.com'">click me</span>
kind regards
Yes, it works with that but if I try to put a URL in within our internal web app, it doesn't change until the PDF is created. I am starting to wonder if this is some sort of limitation on Ajax

Thoughts?
Jul 18 '08 #18
gits
5,390 Expert Mod 4TB
could you try it with firefox and install the firebug extension? then have a look at its errorconsole where we might see what error occurs and find out where the problem might be ... i'm not aware of any problem that you describe ... we use the pdf-creation in the same systematic way as you i told you without problems.

kind regards
Jul 19 '08 #19

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

Similar topics

2
by: Jeannie | last post by:
I have a popup window which is a slideshow of about 7 images. When the popup window loads, the first image is present and then the viewer can select next or previous to scroll through the rest of...
5
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore...
4
by: Randell D. | last post by:
Folks, I have a javascript function which is a popup - It contains a list in form tags - When the user selects a value in the popup, and clicks submit, I want the values to be transfered to the...
9
by: Robby Bankston | last post by:
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
4
by: Matt Jensen | last post by:
Howdy all Hopefully I can explain my problem straightforwardly. In it's simplest explanation, what I want to do is have a hyperlink that, when clicked, executes some client side JavaScript and...
4
by: E | last post by:
I am having trouble with setTimeout working on a second call to the setTimeout function from a second page which is an html page. Here is the scenario. I have a web page and onload it calls a...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.