473,839 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

responseText and IE issue

4 New Member
Hi, I'm working with the responseText on IE but I have a problem with it

I make this

var test = xmlhttpobject.r esponseText;

alert(test);

there is no problem with those two lines, the problem is that I'm sending from the server the word "si" and what I get in variable is a 5 characters word.

Then whe I'm trying to verify the word that I'm recieving with this

Expand|Select|Wrap|Line Numbers
  1.                      for( var i=0 ;  i<test.length ; i++)
  2.         {
  3.         if (  test[i] == 's' )
  4.              if ( test[i+1] == 'i' )
  5.             test="si";
  6.                     }
  7.  
  8.  
and then I do

if ( test == "si")
document.locati on.href = "url";

doesn't work and always get into the else statement of the if that didn't put it here.

When I'm verifiying the what the test variable containt with alert(test[i]) always say Undefined for all the characters even if the string has the letters "s" and "i"

The funny thing is that this work on Mozilla Firefox like with almost all the other things

Can someone help me with it?
Feb 10 '08 #1
4 1511
acoder
16,027 Recognized Expert Moderator MVP
You're resetting test within the for loop. Use charAt to get the character within the string.
Feb 11 '08 #2
Jay10k
4 New Member
Ohh sorry I forget one line into the if statement

for(var i=0; i<test.length ; i ++)

if(test[i] == 's')
if(test[i+1] == 'i')
{
test = "si"
break;
}

I do actually reset test cause as I said before the string length is of 5 elements and if I compare test == "si" it doesn't match ... even when I'm getting the string back from the server ...


And thank you anyway for your help I will try as you say ...
Feb 11 '08 #3
Jay10k
4 New Member
Yes you got it, the problem was resolved thank you very much for your help :)
Feb 11 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
You're welcome. Post again if you have more questions.
Feb 11 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
5591
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla, using the same HTML/JS it always returns no data (xmlhttp.responseText is null). When I try to get headers using Mozilla or display the http status code I get some obscure exception in the javascript console that I've given up on searching for an...
3
3565
by: e271828 | last post by:
I'm trying to access the source of an HTML page with as few alterations from the actual source (as in, that seen from the View Source option) as I can. The method document.documentElement.innerHTML returns the HTML source, but adds HEAD and other elements if they are absent from the source, and takes out whitespace (i.e., line feeds, carriage returns and tabs) within tags and between tags. The follow function: function xhr() { xhr =...
6
7822
by: mihirnmehta | last post by:
This is my code function getDetails() { var name = document.getElementById("movie_name").value; if (window.XMLHttpRequest) //For Mozilla Browsers { XMLHttp=new XMLHttpRequest() }
1
4311
by: KAS | last post by:
First of all, I am very much a newbie... From what I have read, it seems to me that both of these should be filled in all the time. The responseXML being a DOM representation and the responseText being a string representation of the response. Right? If so, then why do I sometimes have a responseText with no responseXML? A second part to that question is accessing the data in responseText. Here is what I have done. On the server side,...
4
5115
by: -Lost | last post by:
For example: var newlines = 'a\n\nb\n\nc'; alert(newlines); Yet, if I get that *exact* same line from an XMLHttpRequest's responseText, it is always alerted as: a\n\nb\n\nc
3
19065
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field on my webpage. I get back that my readyState is 4 and my status is 200 and status text is "OK", but my responseText is always empty. Both on FireFox and IE7, so it must be something I'm doing (wrong). I've also set up an IFRAME to redirect the...
1
9047
by: farghal | last post by:
Hello as many people I'm new to ajax but trying my best to understand. At this point I got a problem I'm not able to solve. I've looked on several forums and googled internet but I can't find a solution :S. This is the basic idea: I'm trying to implement Ajax in a Portal page created in weblogic 9.2. I've created a portlet with the name Ajax.jsp and an additional page called test.jsp. Ajax.jsp is the main portlet page. And uses the...
6
3150
by: lazukars | last post by:
Hi, I am attempting an ajax request. I am using PHP serverside. Below is what the response text should be. ajaxRequest.responseText ="{username_is_taken : "This username has been taken",}" However, the only way I can get the responseText to work on a website via an alert is to take out the comma before the curly bracket. By taking out I mean just not printing the comma with the rest of the string in PHP. If I take out this comma...
5
6639
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns it as the responseText. I want to attach that object to the document (or anywhere else that would allow me to access it later), and to do that, I THINK I need to eval it because it's just a string otherwise. My problem is as soon as I execute a...
0
9855
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, 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...
0
9697
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10649
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10295
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 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...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7018
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();...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4487
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
2
4064
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.