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

Why they write the get method of ajax like this?

aj.get = function(targetUrl, resultHandle) {
aj.targetUrl = targetUrl;
aj.XMLHttpRequest.onreadystatechange =
aj.processHandle;
aj.resultHandle = resultHandle;
if(window.XMLHttpRequest) {
aj.XMLHttpRequest.open('GET', aj.targetUrl);
aj.XMLHttpRequest.send(null);
} else {
aj.XMLHttpRequest.open("GET", targetUrl, true);
aj.XMLHttpRequest.send();
}
}

Some one tell me this is a standard?

Why they write the "get" method like this?

if(window.XMLHttpRequest) {
aj.XMLHttpRequest.open('GET', aj.targetUrl);
aj.XMLHttpRequest.send(null);
} else {
aj.XMLHttpRequest.open("GET", targetUrl, true);
aj.XMLHttpRequest.send();
}

But not directly write

aj.XMLHttpRequest.open('GET', aj.targetUrl);
aj.XMLHttpRequest.send(null);

what is the difference???

Jul 15 '07 #1
1 1253
VK
On Jul 15, 4:43 pm, "jidixuel...@gmail.com"
Why they write the "get" method like this?

if(window.XMLHttpRequest) {
aj.XMLHttpRequest.open('GET', aj.targetUrl);
aj.XMLHttpRequest.send(null);
} else {
aj.XMLHttpRequest.open("GET", targetUrl, true);
aj.XMLHttpRequest.send();
}
Who are "they"? sounds scary :-)
The code above is an ugly Cargo Cult coding sample. The bottom brunch
was originally intended for IE - it is still visible by send() instead
of send(null) statement. But obviously the text passed through a
number of people having no clue what are they saying (doing), so now
it is all mixed up and it is what it is: a pointless chunk of
statements.

Jul 15 '07 #2

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

Similar topics

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...
2
by: Steve Kershaw | last post by:
I have a problem that I need to be able to run a server side method (MyMethod()) from a javascript script. For example: <script language="javascript"> confirmValue = confirm("Do you wish to...
1
by: Dica | last post by:
i'm using the same ajax method in my codeBehind on about 5 different pages. each ajax method is exactly the same, so i wanted to put it in a module and just call from there, but this gives me a...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
10
by: HugeBob | last post by:
Hi All, I'm having a problem with a web app I'm writing. I have a form for which I'm going to validate one of the fields. I use AJAX to retrieve XML containing a list of valid entries. My app...
5
by: nmsreddi | last post by:
Hello friends i am developing ajax enabled wesite in asp.net2.0 and c# in the webforms where ever i am using update panel of ajaxtoolkit Respose.write is not working ,on ther form where there...
4
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there a way to run my javascript method on every async postback? thanks, rodchar
4
by: WT | last post by:
Hello, How could we simulate the IsClientScriptBlocRegistered method of ClientScript when we use an update panel and the static ScriptManager ? Is this test already included in the...
7
by: Jim in Arizona | last post by:
I'm brand new at ajax. In fact, about 20 minutes ago was the first time I got it to work. The problem I'm having on another page did not work, however. I'm running into the following error: ...
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: 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...
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
marktang
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.