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

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 2090
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
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
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
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
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
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
isladogs
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 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.