Click here to get back home

Garbage characters from PHP to Javascript

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Garbage characters from PHP to Javascript jerm 07-17-2008
Posted by jerm on July 17, 2008, 11:44 am
Please log in for more thread options
Hi,

I make a AJAX call to PHP and get back a string to my javascript
function that looks like this:

(0,0)-(1,1)-(25,32)

In my javascript i break the string on the "-" character into an array
like this:

[(0,0)] [(1,1)] [(25,32)]

I check the length of the string in my array at the first position and
it says the length is 7.
I do a length of a hardcoded string "(0,0)" and it is of length 5.

If I do a search of my string and find the position of the "("
character is says it is at postion 2.... this is quite messed up.
Does any one have any idea what is happening here?

Thanks,
Jeremiah

Posted by theiviaxx on July 17, 2008, 1:31 pm
Please log in for more thread options
> Hi,
>
> I make a AJAX call to PHP and get back a string to my javascript
> function that looks like this:
>
> (0,0)-(1,1)-(25,32)
>
> In my javascript i break the string on the "-" character into an array
> like this:
>
> [(0,0)] [(1,1)] [(25,32)]
>
> I check the length of the string in my array at the first position and
> it says the length is 7.
> I do a length of a hardcoded string "(0,0)" and it is of length 5.
>
> If I do a search of my string and find the position of the "("
> character is says it is at postion 2.... this is quite messed up.
> Does any one have any idea what is happening here?
>
> Thanks,
> Jeremiah

not sure what exactly is happening, but a better method would be to
encode the results from php in JSON, then decode it on the javascript
end. That way you dont have to do the splits and the integrity of the
data is maintained.

Posted by Tim Roberts on July 18, 2008, 2:03 am
Please log in for more thread options
>
>I make a AJAX call to PHP and get back a string to my javascript
>function that looks like this:
>
>(0,0)-(1,1)-(25,32)
>
>In my javascript i break the string on the "-" character into an array
>like this:
>
>[(0,0)] [(1,1)] [(25,32)]
>
>I check the length of the string in my array at the first position and
>it says the length is 7.
>I do a length of a hardcoded string "(0,0)" and it is of length 5.
>
>If I do a search of my string and find the position of the "("
>character is says it is at postion 2.... this is quite messed up.
>Does any one have any idea what is happening here?

Well, what you describe would certainly be the case if the string contained
exactly what you said: [(0,0)] That has a length of 7 and ( is in the 2nd
position.

However, my crystal ball is on the blink. Perhaps you should post your
Javascript code, if you are willing to risk the wrath of various
"off-topic" compaints.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Similar ThreadsPosted
How to convert HTML special characters to the real characters with a Java script March 21, 2006, 1:26 pm
Garbage collection April 26, 2007, 8:10 pm
PHP memory garbage collection April 5, 2005, 2:19 pm
Garbage collection problem? October 10, 2005, 2:33 pm
PHP/HTML displays garbage ... November 27, 2005, 7:32 pm
Session garbage collection query November 17, 2006, 2:00 pm
Garbage collector problem with sessions September 4, 2007, 12:02 am
Replace special characters by non-special characters November 5, 2004, 11:08 pm
non-utf characters and XML November 8, 2007, 1:02 am
opendir with dir with odd characters August 1, 2004, 8:51 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap