Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-15-2010, 11:09 PM   PM User | #1
cfgovinda
New Coder

 
Join Date: Apr 2009
Posts: 29
Thanks: 1
Thanked 0 Times in 0 Posts
cfgovinda is an unknown quantity at this point
why is ajax response text prefixing and suffixing white space?

Hi All

I am learning JS and ajax.. successfully writing my own working scripts.. but, being a newbie, still hit the wall alot. Today's wall really has me stumped:

Developing locally, I am calling a page with a working XMLHttpRequest object.. and getting the response, fine. The problem is that the response is coming back with some space chars tacked on. There are like 10-12 space chars prefixed, and one space char suffixed to my response text. Even if I just stick in a single "a" char in the (now static) page that I call, it still returns:
"<space><space><space><space><space><space><space><space><space><space><space>a<space>"
Why?!
Anyway, being a hacker for a living ;-), I attempt to just get around the issue (and understand what happened another day), with something like this:
...
Code:
myResponseTextHack = myObject.responseText;
myResponseTextHack = myResponseTextHack.replace(/ /g,'~');
...which does change *internal* space chars to tilda chars... *BUT* the darn thing STILL has the prefixing and suffixing space chars.
Why?!

Can anyone guide me here?
Thanks so much,
-Govinda
cfgovinda is offline   Reply With Quote
Old 07-21-2010, 11:51 AM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Quote:
Originally Posted by cfgovinda View Post
The problem is that the response is coming back with some space chars tacked on.
Sounds like it is a server-side matter, not an AJAX one. Check your server-side code which supposes to return/echo the response to the AJAX object.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 07-21-2010, 01:48 PM   PM User | #3
cfgovinda
New Coder

 
Join Date: Apr 2009
Posts: 29
Thanks: 1
Thanked 0 Times in 0 Posts
cfgovinda is an unknown quantity at this point
Hi Kor,

you are right. I finally did track it down to the server-side scripting language parser we are using.. it was a pre-parse script that runs invisibly like a header for every page.. it was returning line feeds that i thought were spaces.

Thanks for replying!, I appreciate it.
-Govinda
cfgovinda is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:51 AM.


Advertisement
Log in to turn off these ads.