473,386 Members | 1,830 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,386 software developers and data experts.

Ajax is not asynchronous

Seriously.

I have a flash animation that I was trying to run during ajax calls -
sort of eyecandy - but it would freeze whenever the ajax call was
being made. Then I found out it wasn't just the flash, it was the
entire page - could scroll, type, do jack.

Asynchronous javascript? Yeah, right. (and before you suggest it, that
isAscync parameter in the open function doesn't seem to do jack unless
I'm not using a boolean correctly)

</sarcasm>
Apr 6 '08 #1
4 1501
Rex the Strange <ro********@widgetinc.comwrites:
Asynchronous javascript? Yeah, right. (and before you suggest it, that
isAscync parameter in the open function doesn't seem to do jack unless
I'm not using a boolean correctly)

</sarcasm>
Nice sarcasm. Show the code.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Apr 6 '08 #2
On Apr 6, 10:54*am, Rex the Strange <roger.m...@widgetinc.comwrote:
On Apr 5, 6:06 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
Rex the Strange <roger.m...@widgetinc.comwrites:
Asynchronous javascript? Yeah, right. (and before you suggest it, that
isAscync parameter in the open function doesn't seem to do jack unless
I'm not using a boolean correctly)
</sarcasm>
Nice sarcasm. Show the code.
--
Joost Diepenmaat | blog:http://joost.zeekat.nl/|work:http://zeekat.nl/

Gladly:

/**********/

function ajax_object (callback_field) {
* * * * var request_object;
* * * * var callback = document.getElementById (callback_field);
* * * * var eyecandy = document.getElementById ("flash_cell");
* * * * var parameters = new ajax_parameters;

* * * * request_object = ajax_object ();

* * * * /********/

* * * * function show_eyecandy () {
* * * * * * * * callback.innerHTML = blank;
* * * * * * * * eyecandy.style ["visibility"] = "visible";
* * * * }// show_eyecandy;

* * * * /********/

* * * * function hide_eyecandy () {
* * * * * * * * callback.style ["visibility"] = "visible";
* * * * * * * * eyecandy.style ["visibility"] = "hidden";
* * * * }// hide_eyecandy;

* * * * /********/

* * * * function ajax_object () {
* * * * * * * * var object;
* * * * * * * * try {
* * * * * * * * * * * * object = new XMLHttpRequest ();
* * * * * * * * } catch (except) {
* * * * * * * * * * * * try {
* * * * * * * * * * * * * * * * object =new ActiveXObject ("Msxml2.XMLHTTP");
* * * * * * * * * * * * } catch (except) {
* * * * * * * * * * * * * * * * try {
* * * * * * * * * * * * * * * * * * * * object = new ActiveXObject ("Microsoft.XMLHTTP");
* * * * * * * * * * * * * * * * } catch (except) {
* * * * * * * * * * * * * * * * * * * * return false;
* * * * * * * * * * * * * * * * }// try
* * * * * * * * * * * * }// try
* * * * * * * * }// try
* * * * * * * * return object;
* * * * }// ajax_object;

* * * * /********/

* * * * this.add_parameters = function (name, value) {
* * * * * * * * parameters.add (name, value);
* * * * }// add_parameters;

* * * * /********/

* * * * this.callback_function = function (data) {
* * * * * * * * if (request_object.readyState != 4) return;
* * * * * * * * callback.innerHTML = request_object.responseText;
* * * * * * * * hide_eyecandy ();
* * * * }// callback_function;

* * * * /********/

* * * * this.send = function (destination) {
* * * * * * * * show_eyecandy ();
* * * * * * * * request_object.onreadystatechange = this..callback_function;
* * * * * * * * request_object.open ("post", destination, true);
* * * * * * * * request_object.setRequestHeader ("Content-Type", "application/x-www-
form-urlencoded; charset=UTF-8");
* * * * * * * * request_object.send (parameters.render ());
* * * * }// this.send;

* * * * /********/

}// ajax_object;

/**********/

function ajax_parameters () {
* * * * var items = [];

* * * * this.add = function (name, value) {
* * * * * * * * items.push (name + "=" + value);
* * * * }// add;

* * * * this.render = function () {
* * * * * * * * return items.join ("&");
* * * * }// render;

}// ajax_parameters;

/**********/
Well, I've shown the code. What am I doing wrong?
Jun 27 '08 #3
VK
On Apr 30, 12:45 am, Rex the Strange <roger.m...@widgetinc.comwrote:
On Apr 6, 10:54 am, Rex the Strange <roger.m...@widgetinc.comwrote:
On Apr 5, 6:06 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
Rex the Strange <roger.m...@widgetinc.comwrites:
Asynchronous javascript? Yeah, right. (and before you suggest it, that
isAscync parameter in the open function doesn't seem to do jack unless
I'm not using a boolean correctly)
</sarcasm>
Nice sarcasm. Show the code.
--
Joost Diepenmaat | blog:http://joost.zeekat.nl/|work:http://zeekat.nl/
Gladly:
/**********/
function ajax_object (callback_field) {
var request_object;
var callback = document.getElementById (callback_field);
var eyecandy = document.getElementById ("flash_cell");
var parameters = new ajax_parameters;
request_object = ajax_object ();
/********/
function show_eyecandy () {
callback.innerHTML = blank;
eyecandy.style ["visibility"] = "visible";
}// show_eyecandy;
/********/
function hide_eyecandy () {
callback.style ["visibility"] = "visible";
eyecandy.style ["visibility"] = "hidden";
}// hide_eyecandy;
/********/
function ajax_object () {
var object;
try {
object = new XMLHttpRequest ();
} catch (except) {
try {
object = new ActiveXObject ("Msxml2.XMLHTTP");
} catch (except) {
try {
object = new ActiveXObject ("Microsoft.XMLHTTP");
} catch (except) {
return false;
}// try
}// try
}// try
return object;
}// ajax_object;
/********/
this.add_parameters = function (name, value) {
parameters.add (name, value);
}// add_parameters;
/********/
this.callback_function = function (data) {
if (request_object.readyState != 4) return;
callback.innerHTML = request_object.responseText;
hide_eyecandy ();
}// callback_function;
/********/
this.send = function (destination) {
show_eyecandy ();
request_object.onreadystatechange = this.callback_function;
request_object.open ("post", destination, true);
request_object.setRequestHeader ("Content-Type", "application/x-www-
form-urlencoded; charset=UTF-8");
request_object.send (parameters.render ());
}// this.send;
/********/
}// ajax_object;
/**********/
function ajax_parameters () {
var items = [];
this.add = function (name, value) {
items.push (name + "=" + value);
}// add;
this.render = function () {
return items.join ("&");
}// render;
}// ajax_parameters;
/**********/

Well, I've shown the code. What am I doing wrong?
That was answered N times in this group: the graphics context is not
being updated until exit from the current execution context. With your
nested functions - besides being memory leaking like an old bucket -
you never give this opportunity to the engine. use setTimeout at
least.

Jun 27 '08 #4
Rex the Strange <ro********@widgetinc.comwrites:
>Gladly:
Ok ok, I didn't reply to your code the first time, because I couldn't
find the error. Though the naming of some of the variables did make my
head hurt. Here's what I've got.
>/**********/

function ajax_object (callback_field) {
Â* Â* Â* Â* var request_object;
Â* Â* Â* Â* var callback = document.getElementById (callback_field);
callbacks are usually functions.
>Â* Â* Â* Â* var eyecandy = document.getElementById ("flash_cell");
Â* Â* Â* Â* var parameters = new ajax_parameters;

Â* Â* Â* Â* request_object = ajax_object ();
I note that you're calling a nested ajax_object() function within this
ajax_object() function. Also the outer function *seems* to be a
constructor, while the inner function isn't. Can't see how you're
calling the outer function, though.
>Â* Â* Â* Â* /********/
Does this mean you've left some code out here?
>Â* Â* Â* Â* function show_eyecandy () {
Â* Â* Â* Â* Â* Â* Â* Â* callback.innerHTML = blank;
Â* Â* Â* Â* Â* Â* Â* Â* eyecandy.style ["visibility"] = "visible";
this is probably better (or at least, shorter) written as

eyecandy.style.visibilitiy = "visible";
>Â* Â* Â* Â* }// show_eyecandy;
Â* Â* Â* Â* /********/

Â* Â* Â* Â* function hide_eyecandy () {
Â* Â* Â* Â* Â* Â* Â* Â* callback.style ["visibility"] = "visible";
Â* Â* Â* Â* Â* Â* Â* Â* eyecandy.style ["visibility"] = "hidden";
same here.
>Â* Â* Â* Â* }// hide_eyecandy;

Â* Â* Â* Â* /********/

Â* Â* Â* Â* function ajax_object () {
Â* Â* Â* Â* Â* Â* Â* Â* var object;
Â* Â* Â* Â* Â* Â* Â* Â* try {
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* object = new XMLHttpRequest ();
Â* Â* Â* Â* Â* Â* Â* Â* } catch (except) {
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* try {
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* object = new ActiveXObject ("Msxml2.XMLHTTP");
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* } catch (except) {
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* try {
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* object = new ActiveXObject ("Microsoft.XMLHTTP");
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* } catch (except) {
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* return false;
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* }// try
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* }// try
Â* Â* Â* Â* Â* Â* Â* Â* }// try
Â* Â* Â* Â* Â* Â* Â* Â* return object;
Â* Â* Â* Â* }// ajax_object;

Â* Â* Â* Â* /********/

Â* Â* Â* Â* this.add_parameters = function (name, value) {
Â* Â* Â* Â* Â* Â* Â* Â* parameters.add (name, value);
Â* Â* Â* Â* }// add_parameters;

Â* Â* Â* Â* /********/

Â* Â* Â* Â* this.callback_function = function (data) {
Â* Â* Â* Â* Â* Â* Â* Â* if (request_object.readyState != 4) return;
Â* Â* Â* Â* Â* Â* Â* Â* callback.innerHTML = request_object.responseText;
Â* Â* Â* Â* Â* Â* Â* Â* hide_eyecandy ();
Â* Â* Â* Â* }// callback_function;

Â* Â* Â* Â* /********/

Â* Â* Â* Â* this.send = function (destination) {
Â* Â* Â* Â* Â* Â* Â* Â* show_eyecandy ();
Â* Â* Â* Â* Â* Â* Â* Â* request_object.onreadystatechange = this.callback_function;
Â* Â* Â* Â* Â* Â* Â* Â* request_object.open ("post", destination, true);
Â* Â* Â* Â* Â* Â* Â* Â* request_object.setRequestHeader ("Content-Type", "application/x-www-
form-urlencoded; charset=UTF-8");
Â* Â* Â* Â* Â* Â* Â* Â* request_object.send (parameters.render ());
Â* Â* Â* Â* }// this.send;

Â* Â* Â* Â* /********/

}// ajax_object;

/**********/

function ajax_parameters () {
Â* Â* Â* Â* var items = [];

Â* Â* Â* Â* this.add = function (name, value) {
Â* Â* Â* Â* Â* Â* Â* Â* items.push (name + "=" + value);
Â* Â* Â* Â* }// add;

Â* Â* Â* Â* this.render = function () {
Â* Â* Â* Â* Â* Â* Â* Â* return items.join ("&");
Â* Â* Â* Â* }// render;
this will break if your names or values contain any characters that need to
be urlencoded.
>}// ajax_parameters;

/**********/

Well, I've shown the code. What am I doing wrong?
Dunno. Got a URL?

Joost.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but...
7
by: JM | last post by:
Hi, I transferred an AJAX application to the server to be used across the Internet. On my localhost, it works great. But when I transferred it to the server, the user control freezes for a...
23
by: ivan | last post by:
AJAX is a stupid and confusing word. People is wondering for something that programmers have used for many years. Javascript + Xml and asynchronous requests is not new. People started to speak...
1
by: Louis-Philippe Dumoulin | last post by:
Hi, I have the following problem in asp 1.1. On my web page, when I click on a menu, a postback is generated. On the post back, I create dynamically with LoadControl a WebGrid (from InterSoft)...
2
by: hardrock | last post by:
Hello! I'm working with the prototype library version 1.4.0 and having a strange error lately. When I want to make an Ajax.Updater call, it basically works. But as soon as I put the call into...
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
2
by: dmagliola | last post by:
Hello all, I'm experiencing a problem with ASP.Net for which I can't find a reasonable explanation, or any information. I'm currently developing an application that, through AJAX, asks the...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
29
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to...
6
by: sheldonlg | last post by:
I came across a problem and googling for an answer didn't help. What I want to do is run an AJAX script that sets a hidden variable on the form. I call the AJAX script from a javascript...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
jinu1996
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...

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.