Hi,
I need to evaluate the return result of a function from Server.aspx as following. But it doesn't work as I need - function getAjax()
-
{
-
var XmlHttp;
-
//Creating object of XMLHTTP in IE
-
try
-
{
-
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch(e)
-
{
-
try
-
{
-
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch(oc)
-
{
-
XmlHttp = null;
-
}
-
}
-
//Creating object of XMLHTTP in Mozilla and Safari
-
if(!XmlHttp && typeof XMLHttpRequest != "undefined")
-
{
-
XmlHttp = new XMLHttpRequest();
-
}
-
return XmlHttp;
-
}
-
function GetBanType()
-
{
-
rnd++;
-
-
url = 'Server.aspx?action=GetBan&session=' + rnd ;
-
var re = getAjax();
-
-
re.onreadystatechange = function(){
-
if( re.readyState == 4 && re.status == 200 )
-
{
-
if(re.responseText != "")
-
{
-
if (re.responseText == "special value")
-
{
-
....
-
Actually, re.responseText returns:
"Gag
<br />
<br />
<br />
<br />
<br />
<br />
"
while I'm expecting only "Gag" word.
Could I know how I can subtract only the first word of the return result? Or, is there any general solution to get a proper result from server .aspx
Any idea is appreciated.
6 2456 acoder 16,027
Recognized Expert Moderator MVP
Remember to use code tags when posting code:
[CODE=javascrip t]JS code here...[/code]
Your server-side script is displaying extra spaces and newlines. Get rid of them.
You could replace all spaces and newlines in the response too.
If the response from the server is incorrect, then the server must be coded incorrectly in some way. I could not find anything wrong with the javascript code, so check your server.aspx's code to make sure there are not any mistakes that could have caused this error.
Hope I helped!
Thanks John and acoder for replying!
I call following function in server.aspx: - private void processGetBan()
-
{
-
lock (syncRoot)
-
{
-
string user = (string)Session["username"];
-
string channelname = (string)Session["channel"];
-
Response.Write(Global.Engine.GetChannel(channelname).GetBanType(user));
-
}
-
}
in which GetBanType() returns only "Gag" without any space, etc.
Is there anything wrong with my server code?
acoder, you've written that I can replace all spaces and newlines in the response too; could you please tell me how, through a sample? I'm new in javascript/ajax code
acoder 16,027
Recognized Expert Moderator MVP
Run the server-side code without Ajax and check the source code.
To remove spaces/newlines, use the string replace method.
Thank you very much acoder
acoder 16,027
Recognized Expert Moderator MVP Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Markus Schuster |
last post by:
Hi,
I have the following javascript function:
<script type="text/javascript">
function HTMLEncode( text )
{
text = text.replace(/&/g, "&") ;
text = text.replace(/"/g, """) ;
|
by: Phlip |
last post by:
Javascripters:
I have an outer page and an inner iframe. The outer page calculates some
javascript, and wants the inner frame to run it. The inner frame should hit
a page on the same (private) web server, so this is not a cross-site
scripting attack. But I would prefer not to taint the target page with any
extra logic to do this. (I will if I must.)
The calling page has these elements:
|
by: trey.bason |
last post by:
I know everyone who uses javascript at some point tries to think of a
way to hide it from curious users/hackers, so here goes my question.
I am trying to display an image map and keep the coords of the active
areas hidden from users. I have a page named test.htm that includes a
file get.php in a <scripttag that will dynamically generate some
javascript to write the imagemap. The get.php file will write a unique
key to a session that will...
|
by: julie.siebel |
last post by:
I'm working on a rather complex booking system for building European
trips, in a combination of SQL/VBScript/Javascript. There are tons of
query string variables that get passed back and forth between the
pages, and in almost every case, I can set 'em up fine, provided the
variables are in the link.
The page the *holds* the booking information, though, is problematic.
An example trip might include two European cities or towns with a...
|
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...
| |
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
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...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |