...

View Full Version : Wait for finish print



Pattatj
09-27-2011, 09:38 AM
Hey there guys, I'm working with an AJAX request that returns some stuff to print in 2 boxes. All working great, so I decided to make something fluffy, when I click a result in the AJAX request, he filters the clicked result, so you only see that clicked row. When clicked again, the old results will return. All working great.

Now, my problem, I wanted a checkbox after every row in the search results and when the user clicks twice on a result to filter it and than goes back to the old results to check the checkboxes again that were checked before filtering that component.

I made the functions and it didn't work till I put some alerts in, when the return function got some time to finish printing (like with the user had to click on OK in the alert) it worked. When I deleted the alerts, it didn't work again...

I searched on the internet, found a function to wait for an image to load or smth similar and I found some guys that used a function to wait for a specific time (1 sec for example) and that's not what I want. If I use a specific waittime it can still fail if the PC is slow, or whatever, it's just not nice coding.

So, is there something I can do so it waits till my AJAX request has been printed?


Thanks!

'x.

ironboy
09-27-2011, 07:03 PM
Disable the buttons while waiting for the ajax response.

In general you avoid much headache by disabling user input whilst waiting for the result of the last similar user input ;)
And you can be nice about it to:
If the wait is short you can let a button have a "pressed down" look while disabled.
If the wait is longer it could have a rotating symbol or something similar.

Pattatj
09-29-2011, 03:48 PM
Disable the buttons while waiting for the ajax response.

In general you avoid much headache by disabling user input whilst waiting for the result of the last similar user input ;)
And you can be nice about it to:
If the wait is short you can let a button have a "pressed down" look while disabled.
If the wait is longer it could have a rotating symbol or something similar.

I'm not really sure if you understand me right, I have no buttons :o
I'm doing an AJAX request that needs to print some checkboxes, outside the AJAX request, a JavaScript function searches for these checkbox ID's and checks them if they were checked before the AJAX request started. My problem is that the JavaScript function searches for these ID's before the AJAX response was printed, so the checkboxes are not there yet. So he probably can't find these ID's and just moves on, so I wanna wait for the AJAX response to be printed before I check for those ID's.

Thanks again! :D

'x.

Pattatj
10-05-2011, 08:07 AM
Anyone got an idea? Still got the problem... :(

'x.

Pattatj
10-06-2011, 01:10 PM
*Bump*
Searched some around on the internet and really can't find a thing, it's okay if these posts get deleted for spam. I just want to know if someone knows something for this.

Is there no one else with this problem?

'x.

Philip M
10-06-2011, 01:31 PM
I made the functions and it didn't work till I put some alerts in, when the return function got some time to finish printing (like with the user had to click on OK in the alert) it worked. When I deleted the alerts, it didn't work again...

I searched on the internet, found a function to wait for an image to load or smth similar and I found some guys that used a function to wait for a specific time (1 sec for example) and that's not what I want. If I use a specific waittime it can still fail if the PC is slow, or whatever, it's just not nice coding.


There is no way to detect that actual printing has finished.

Try using the 1-second delay technique you mention - but in fact only a few milliseconds delay may be enough. There are several instances in both IE and FF where a short delay must be introduced - enough to allow the browser to "catch up". That is what your alerts are doing. It is nothing to do with whether the PC is slow or not.

Pattatj
10-06-2011, 01:50 PM
There is no way to detect that actual printing has finished.

Try using the 1-second delay technique you mention - but in fact only a few milliseconds delay may be enough. There are several instances in both IE and FF where a short delay must be introduced - enough to allow the browser to "catch up". That is what your alerts are doing. It is nothing to do with whether the PC is slow or not.

Thanks a lot for your response, I will use a delay, thanks!

'x.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum