473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX Problem

in my script i declared one variable as global.I am tying to acess it
in a function but it is not comming in Mozilla . it is executing in
ie.

My code is

var http = createRequestObject();
function createRow(key,val,tableId,index,numele,evt)
{
var table = document.getElementById(tableId);
var newRowFlag = false;
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
switch(charCode)
{
case 13 :
case 9 : if(parseInt(table.rows.length) ==
(parseInt(index)))
newRowFlag=true;
}
if(newRowFlag)
{
http.open('get',"gridClass.php?rowkey="+key
+"&rowval="+val
+"&index="+index+"&tabid="+tableId);
http.onreadystatechange = function(){

insertRow(tableId,index,numele);};
http.send(null);
}

}

function insertRow(tableId,index,numele)
{
alert(http.readystate);
if(http.readystate == '4')
{
var response = http.responseText;
var table = document.getElementById(tableId);
var td = response.split('^');
newRow = table.insertRow();
for(i=0;i<numele;i++)
{
isText = newRow.insertCell(i);
isText.innerHTML = td[i];
}
}

}

Thanks in advance
Ravindra

May 24 '07 #1
5 2096
On May 24, 3:16 pm, Ravi <Ravindrayep...@gmail.comwrote:
in my script i declared one variable as global.I am tying to acess it
in a function but it is not comming in Mozilla . it is executing in
ie.

My code is

var http = createRequestObject();
function createRow(key,val,tableId,index,numele,evt)
{
var table = document.getElementById(tableId);
var newRowFlag = false;
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
switch(charCode)
{
case 13 :
case 9 : if(parseInt(table.rows.length) ==
(parseInt(index)))
newRowFlag=true;
}
if(newRowFlag)
{
http.open('get',"gridClass.php?rowkey="+key
+"&rowval="+val
+"&index="+index+"&tabid="+tableId);
http.onreadystatechange = function(){

insertRow(tableId,index,numele);};
http.send(null);
}

}

function insertRow(tableId,index,numele)
{
alert(http.readystate);
if(http.readystate == '4')
{
var response = http.responseText;
var table = document.getElementById(tableId);
var td = response.split('^');
newRow = table.insertRow();
for(i=0;i<numele;i++)
{
isText = newRow.insertCell(i);
isText.innerHTML = td[i];
}
}

}

Thanks in advance
Ravindra
The most important thing that you didn't show is what the
createRequestObject() function does. That's probably the reason for
your problems, because you've probably written it as such to conform
only to IE "standards" (notice the quotes).

May 24 '07 #2
On May 24, 9:25 pm, Darko <darko.maksimo...@gmail.comwrote:
On May 24, 3:16 pm, Ravi <Ravindrayep...@gmail.comwrote:
in my script i declared one variable as global.I am tying to acess it
in a function but it is not comming in Mozilla . it is executing in
ie.
My code is
var http = createRequestObject();
function createRow(key,val,tableId,index,numele,evt)
{
var table = document.getElementById(tableId);
var newRowFlag = false;
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
switch(charCode)
{
case 13 :
case 9 : if(parseInt(table.rows.length) ==
(parseInt(index)))
newRowFlag=true;
}
if(newRowFlag)
{
http.open('get',"gridClass.php?rowkey="+key
+"&rowval="+val
+"&index="+index+"&tabid="+tableId);
http.onreadystatechange = function(){
insertRow(tableId,index,numele);};
http.send(null);
}
}
function insertRow(tableId,index,numele)
{
alert(http.readystate);
if(http.readystate == '4')
{
var response = http.responseText;
var table = document.getElementById(tableId);
var td = response.split('^');
newRow = table.insertRow();
for(i=0;i<numele;i++)
{
isText = newRow.insertCell(i);
isText.innerHTML = td[i];
}
}
}
Thanks in advance
Ravindra

The most important thing that you didn't show is what the
createRequestObject() function does. That's probably the reason for
your problems, because you've probably written it as such to conform
only to IE "standards" (notice the quotes).

function createRequestObject() {
var tmp;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
tmp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
tmp = new XMLHttpRequest();
}
return tmp;
}
This is the function my problem is in insertRow function http variable
is becomming local.It is not giving any response.

May 25 '07 #3
Ravi wrote:
On May 24, 9:25 pm, Darko <darko.maksimo...@gmail.comwrote:
>On May 24, 3:16 pm, Ravi <Ravindrayep...@gmail.comwrote:
<snip code>
>The most important thing that you didn't show is what the
createRequestObject() function does. That's probably the reason for
your problems, because you've probably written it as such to conform
only to IE "standards" (notice the quotes).

function createRequestObject() {
var tmp;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
tmp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
tmp = new XMLHttpRequest();
}
return tmp;
}
This is the function my problem is in insertRow function http variable
is becomming local.It is not giving any response.
Your problem is using horribly written browser sniffing code. Try
feature detecting and definitely take a look at:

http://jibbering.com/faq/index.html#FAQ4_44

Granted, this is not your entire solution. It is merely a starting point.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 25 '07 #4
On May 25, 8:13 am, -Lost <maventheextrawo...@techie.comwrote:
Ravi wrote:
On May 24, 9:25 pm, Darko <darko.maksimo...@gmail.comwrote:
On May 24, 3:16 pm, Ravi <Ravindrayep...@gmail.comwrote:

<snip code>
The most important thing that you didn't show is what the
createRequestObject() function does. That's probably the reason for
your problems, because you've probably written it as such to conform
only to IE "standards" (notice the quotes).
function createRequestObject() {
var tmp;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
tmp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
tmp = new XMLHttpRequest();
}
return tmp;
}
This is the function my problem is in insertRow function http variable
is becomming local.It is not giving any response.

Your problem is using horribly written browser sniffing code. Try
feature detecting and definitely take a look at:

http://jibbering.com/faq/index.html#FAQ4_44

Granted, this is not your entire solution. It is merely a starting point.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
OK, it's true what Lost said, but it's not the reason for your errors.
It's some stupid syntax errors that you've made, that took me a while
to notice. First, in the open() call, you have to pass "true" as the
last argument (which you didn't do), that says you want asynchronous i/
o (as almost all ajax programmers do). The second thing, you don't
check for http.readystate, but http.readyState (capital 'S') -
Javascript is case-sensitive. Third, what Lost said, you've got much
too simple getAjax-function, take a look at the following (which I
use), it might be of help:
function getAJAXHandler()
{
var http = null;
try {
if (window.XMLHttpRequest) // Mozilla, Safari,...
http = new XMLHttpRequest();
else if (window.ActiveXObject) { // IE
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
} catch ( e ) {}
return http;
}
If you get null for this function, that means the browser you have
either doesn't support ajax or isn't handled well by the function. But
should work well.

May 25 '07 #5

Thanks Darko but tell me one thing why it is executing in IE if
javascript is case sensitive then it should not work in IE also.

May 26 '07 #6

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

Similar topics

5
2193
by: Martin | last post by:
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...
3
1668
by: Alok yadav | last post by:
I have an open IP and on that IP our main application is hosted. it uses ajax. in web.config file i have register ajax handlers. there are also other sites or project on that IP. now my problem is...
3
3112
by: equazcion | last post by:
Hi, I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
2
3121
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
2
1646
by: majidtou | last post by:
Hi , We have an HTML page which is using AJAX. We make an AJAX call which retrieves a table with mutiple rows. We need to extend this functionality. In the table, we want to put a button on each...
0
7002
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
7165
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
7205
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...
1
6887
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
7379
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...
1
4910
isladogs
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.