Folks,
Short version:
Has anyone tried a synchronous call ("SJAX") to a server with the
Prototype library? I'm curious if there is a bug in the library
(possible) or if I am making mistake (probable).
Longer version:
I am updating a tree structure by using an Ajax call with Prototype.
The response handler adds nodes to the DOM (w3c-style -- not
innerHTML). However, other Javascript does not "see" the new nodes.
The logging suggests that the handler is being fired off in the
background asynchronously.
Here's a snippet:
var myAjax = new Ajax.Request( myUrl ,
{
method: 'get',
parameters: '',
options: { asynchronous: false }, // ??
onComplete: function(respon se) {
var text = response.respon seText;
treeData = eval('(' + text + ')');
myPopulate(tree Data);
}
});
checkForNodes() ; // this should not execute until after the myPopulate
handler completes
I'm a Java guy who does not work with Javascript often. Is there an
inherent problem with this setup?
Any help is greatly appreciated... crunch time here.
thanks,
Mike ke*********@hot mail.com 4 10553
ps. Note that my concern here is timing... The nodes are indeed created
so the data from the server is fine etc. It's just that the
checkForNodes() code asks for the children of a div and it doesn't work
until the 2nd or 3rd click. ke*********@hot mail.com wrote:
Folks,
Short version:
Has anyone tried a synchronous call ("SJAX") to a server with the
Prototype library? I'm curious if there is a bug in the library
(possible) or if I am making mistake (probable).
Longer version:
I am updating a tree structure by using an Ajax call with Prototype.
The response handler adds nodes to the DOM (w3c-style -- not
innerHTML). However, other Javascript does not "see" the new nodes.
The logging suggests that the handler is being fired off in the
background asynchronously.
Here's a snippet:
var myAjax = new Ajax.Request( myUrl ,
{
method: 'get',
parameters: '',
options: { asynchronous: false }, // ??
onComplete: function(respon se) {
var text = response.respon seText;
treeData = eval('(' + text + ')');
myPopulate(tree Data);
}
});
checkForNodes() ; // this should not execute until after the myPopulate
handler completes
I'm a Java guy who does not work with Javascript often. Is there an
inherent problem with this setup?
Any help is greatly appreciated... crunch time here.
thanks,
Mike ke*********@hot mail.com
Synchronous server calls are generally considered a Bad Idea. I know it
seems easier to not have to mess with the callback, but the problem is
that while the call is blocking, the browser typically locks up. This
could be seen as an implementation problem with the browsers, but AFAIK,
every browser that implements javascript HTTP Requests behaves this way.
The consequence of this is that if your server is slow or not
responding, the browser can lock up for a long time or even permanently.
Try porting your code to the callback model - it's actually pretty easy,
although it might seem like a pain at first.
Jeremy
thanks, Jeremy... Your post helped me realize, with stunning insight,
that with some refactoring it doesn't matter if the call is
asynchronous.
For any one else reading this, the gist of the idea is if
function checkNodes() {
doStuff1();
doStuff2();
}
then by breaking out doStuff2() into its own function I can do:
var myAjax = new Ajax.Request( url, function() {
// as before
doStuff2();
}
); ke*********@hot mail.com wrote:
thanks, Jeremy... Your post helped me realize, with stunning insight,
that with some refactoring it doesn't matter if the call is
asynchronous.
Yes, that's a great thing to realize. However, in order to automate the
refactoring you describe, did anyone have some experience with Narrative
Javascript ( http://neilmix.com/narrativejs/doc/index.html ) ? If I
understand correctly, it is a javascript preprocessor that should allow
you to write your checkNodes function as follows:
function checkNodes() {
doStuff1->(); // This operation will block, so please
// resume execution only after its complete
doStuff2();
}
Cheers,
Alexis
For any one else reading this, the gist of the idea is if
function checkNodes() {
doStuff1();
doStuff2();
}
then by breaking out doStuff2() into its own function I can do:
var myAjax = new Ajax.Request( url, function() {
// as before
doStuff2();
}
); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Larry Bud |
last post by:
More of a design question than technical.... combining Ajax technology
with ASP... Top portion of the page contains several Select boxes
which are dependant upon one another. Ajax handles that pretty well,
although when reloading the page, I have to "draw" each one, which the
user can see....
Once the search criteria is chosen, user clicks a Find button...
Currently, the entirep page redraws...
Is there any reason NOT to put the...
|
by: Tony |
last post by:
I've done a fair bit of searching on this, but I want to be certain
about what I've found - so here goes with a long example and three
questions:
For clarity, let me give an example (a number of the pages I found had
some ambiguity). Say I have a page with 2 buttons ( A and B, for
simplicity) and each button will make a different "ajax" request, for
data to be placed in a corresponding DIV.
For sake of example, we won't consider...
|
by: blueapricot416 |
last post by:
I have some javascript in a standard HTML page that uses the ubiquitous
"XMLHttpRequest" to send data to a remote ASP page.
If that page "answers back" by sending a string using a simple
Response.Write, which I then use in the original HTML page to
dynamically update stuff, is this "AJAX"?
Specifically, is there anything "wrong" with sending back info from
classic ASP pages using simple Response.Writes? (Is there usually
something...
|
by: Tony Lawrence |
last post by:
Probably a lot of you here are already old hands at Ajax, but I haven't
started doing this yet. Part of the reason was that I really didn't
understand where Ajax would be useful to my own site, and also that my
experiences with early Javascript put me off on that a bit.
"Understanding Ajax" by Joshua Eichorn helped me with both of those
impediments. Complete review at
http://aplawrence.com/Books/understanding_ajax.html
--
|
by: caston |
last post by:
Well, everybody can now agree with the fact that the Ajax hype is over.
Still multiple Ajax Frameworks are flourishing, aren't they?
So, last night I questioned myself with the following: "When Ajax
Frameworks will be gone? What is required to get rid of them and start
using browsers?" (To be more precise, I should probably also mention
what kind of frameworks do i mean. These are: Dojo, BackBase, Qooxdoo
etc.)
I've got an answer that I...
| |
by: pe3no |
last post by:
Hi,
I'm going to create applications PHP + AJAX + Linux + Apache + Postgres.
- Other Open Source technologies / Frameworks, etc. also :)
Is this book http://www.amazon.com/gp/reader/0471777781
suitable for my "case"? I'm asking persons who read this book :)
I wouldn't like to buy something unuseless, which for example
is completely concentrated on .NET, C#, ASP.NET, m$something etc...
|
by: mark4asp |
last post by:
Which should I use:
1. "ASP.NET AJAX-Enabled Web Site" or
2. "AJAX Control Toolkit Web Site"?
In the first, controls from the control toolkit start as:
<cc1:SomeControl></cc1>
In the 2nd, those controls are: <ajaxToolkit:SomeControl></
ajaxToolkit>
|
by: Sommer.pde |
last post by:
It took me some time to find out when and why this happens.
When the window of Internet Explorer is closed with an AJAX call still
pending, something funny happens. Do it twice, and you will have to
restart the browser.
Here a little sample: http://truefriendz.de/iedos
The script on this site will open 5 test-windows one at a time.
|
by: Jonathan Wood |
last post by:
Can anyone point me to any good resources on adding AJAX to a page once the
page has already been created? I know VS2008 has options to add AJAX pages,
but I didn't select those options when the pages were created.
Thanks.
Jonathan
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |