Hello NG,
I've been doing some AJAX for a few weeks now. The basics worked fine so
far, but now I've got the following problem which I can't solve:
With AJAX you typically update/replace only parts of your page. But in
my application there are situation when I first notice on the server --
so AFTER sending an AJAX request -- that I have to update the complete
page instead of only some parts. And what do I do now???
- Possibility 1: (That's how I do it at the moment)
I send the complete html source code to the client and do the following:
document.open();
document.write(complete_html_code);
document.close();
Basically it works, however, my page is destroyed when I press F5
afterwards. It seems like the included CSS and JS in the header are not
"loaded" correctly - even though everything looks and functions
correctly before pressing F5. Any ideas???
- Possibility 2:
For a complete update I only send the URL for the according page to the
client. On the client I extract the this URL from the received XML and
do the following: document.location.href = extractedUrl;
Even though this should work, this solution always requires two requests
- the AJAX-request and the later JS-redirect. Thats not good either...
-Possibility 3:
I'm sure that I'm not the first person having this problem. Are the any
other solutions or maybe even some kind of patters to solve my problem?
Thanks in advance,
Martin 5 2181
Of course the subject should be: "Complete page UPDATE using AJAX"
Sorry,
Martin
Martin wrote:
Hello NG,
I've been doing some AJAX for a few weeks now. The basics worked fine so
far, but now I've got the following problem which I can't solve:
With AJAX you typically update/replace only parts of your page. But in
my application there are situation when I first notice on the server --
so AFTER sending an AJAX request -- that I have to update the complete
page instead of only some parts. And what do I do now???
- Possibility 1: (That's how I do it at the moment)
I send the complete html source code to the client and do the following:
document.open();
document.write(complete_html_code);
document.close();
Basically it works, however, my page is destroyed when I press F5
afterwards. It seems like the included CSS and JS in the header are not
"loaded" correctly - even though everything looks and functions
correctly before pressing F5. Any ideas???
- Possibility 2:
For a complete update I only send the URL for the according page to the
client. On the client I extract the this URL from the received XML and
do the following: document.location.href = extractedUrl;
Even though this should work, this solution always requires two requests
- the AJAX-request and the later JS-redirect. Thats not good either...
-Possibility 3:
I'm sure that I'm not the first person having this problem. Are the any
other solutions or maybe even some kind of patters to solve my problem?
Thanks in advance,
Martin
A better question would be: "Complete page using AJAX, why?!?"
Ask yourself if AJAX is improving the user experience, or simply
complicating development. Is this the purpose for which the technology
was designed?
Remember the KISS principle: "Keep it simple, stupid!" AJAX is icing on
the cake; it's rare that it can be justified for an application's
usefulness to hinge upon it.
Jeremy
Jeremy wrote:
Martin wrote:
Hello NG,
I've been doing some AJAX for a few weeks now. The basics worked fine so
far, but now I've got the following problem which I can't solve:
With AJAX you typically update/replace only parts of your page. But in
my application there are situation when I first notice on the server --
so AFTER sending an AJAX request -- that I have to update the complete
page instead of only some parts. And what do I do now???
I'm going to assume that you're using Ajax for server side validation
of form data and should all data be correct, then you want to go ahead
and submit the action?
- Possibility 1: (That's how I do it at the moment)
I send the complete html source code to the client and do the following:
document.open();
document.write(complete_html_code);
document.close();
Basically it works, however, my page is destroyed when I press F5
afterwards. It seems like the included CSS and JS in the header are not
"loaded" correctly - even though everything looks and functions
correctly before pressing F5. Any ideas???
This is generally speaking a bad idea. You should abandon this practice
immediately.
- Possibility 2:
For a complete update I only send the URL for the according page to the
client. On the client I extract the this URL from the received XML and
do the following: document.location.href = extractedUrl;
This is not that big a deal and is not a bad way to go.
Even though this should work, this solution always requires two requests
- the AJAX-request and the later JS-redirect. Thats not good either...
-Possibility 3:
I'm sure that I'm not the first person having this problem. Are the any
other solutions or maybe even some kind of patters to solve my problem?
Consider something like the following:
<form action="myserverside.php" onsubmit="return checkIt();">
....
</form>
Notice that the form has an action defined which would be the url to
your "next" page. It also has an onsubmit that returns the result of a
checkIt(0 function.
This checkIt() function would do your Ajax request and get the results
from your server. It would then return true should validation pass, or
if validation fails you would perform your page updates and then return
false.
This will still result in the 2 requests you mention in Option 2, but
somehow seems to be a more elegant solution. Why? I dunno...I also
prefer Miracle Whip over mayonnaise.
Thanks in advance,
Martin
A better question would be: "Complete page using AJAX, why?!?"
Ask yourself if AJAX is improving the user experience, or simply
complicating development. Is this the purpose for which the technology
was designed?
Remember the KISS principle: "Keep it simple, stupid!" AJAX is icing on
the cake; it's rare that it can be justified for an application's
usefulness to hinge upon it.
Jeremy
A better question would be: "Complete page using AJAX, why?!?"
I don't have the option to use AJAX or not. My boss and our client wants
it, so the question is definitely "how", not "why".
Regards,
Stephan
I'm going to assume that you're using Ajax for server side validation
of form data and should all data be correct, then you want to go ahead
and submit the action?
No, it's completely different but too complex to explain. So just take
it as a fact that in my application there are definitly some cases where
i have to do a full update after sending an AJAX request.
This is generally speaking a bad idea. You should abandon this practice
immediately.
Hmmm, and why?
This is not that big a deal and is not a bad way to go.
But won't this lead to problems when I later on try to support the back
button?
Consider something like the following:
<form action="myserverside.php" onsubmit="return checkIt();">
...
</form>
This checkIt() function would do your Ajax request and get the results
from your server. It would then return true should validation pass, or
if validation fails you would perform your page updates and then return
false.
As I said, the problem is a bit more complex. It's an existing
application in which I have to integrate AJAX and the current design
forces me to do a full update in certain situations. But is has nothing
to do with form validation.
Regards,
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: 1kHz |
last post by:
Hi all..
I'm new with this Ajax thingy and have done some experimenting. I did
some codes according to examples from
http://www.webpasties.com/xmlHttpRequest/
and...
|
by: Jono |
last post by:
Hi Everyone,
As it says in the title, I'm looking for a way to display a page while
long running operations are performed on the server. Ideally, I'd like
some way to push the current request...
|
by: rocksoft |
last post by:
Hi,
i have devloping web application in Asp.net and c#, i have used ajax to achieve the auto complete text box, my company using visual studio 2003, ajax auto complete text box...
|
by: lmttag |
last post by:
Hello.
We're developing an ASP.NET 2.0 (C#) application and we're trying to
AJAX-enable it. We're having problem with a page not showing the page while
a long-running process is executing. So,...
|
by: empiresolutions |
last post by:
im using the script.aculo.us drag n drop script. i am having an issue getting a checkbox to POST its value if checked, once the row the checkbox is in is moved. I believe that once i change the...
|
by: paulie |
last post by:
Hi,
I have been experiencing an issue when trying to use AJAX to reload a DIV area
using a timer of 2000ms, which contains a html page with another DIV and javascript.
Scenario
-------------...
|
by: hsriat |
last post by:
I have a page working on Ajax. The problem is, after doing many changes using Ajax (like uploading, changing name, adding to favorites etc), the status bar starts behaving unexpectedly. Even when...
|
by: dlite922 |
last post by:
Hey guys been a while since I needed your help.
I've got a reporting system (yes same old one) , one button runs the report and builds the html table into the page all nice with CSS, etc, the...
|
by: Microsoft Newsserver |
last post by:
Hi Folks.
I have an issue I need some help with if thats OK.
I am running Framework 2.0 using Windows Integrated Security. For most of
the application we manage session timeouts without the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| | |