473,486 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Garbage characters from PHP to Javascript

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
Jul 17 '08 #1
2 1260
On Jul 17, 8:44*am, jerm <jerm.hann...@gmail.comwrote:
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.
Jul 17 '08 #2
jerm <je**********@gmail.comwrote:
>
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, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2972
by: lkrubner | last post by:
Pierre Goiffon Oct 6 2004, 4:29 am show options Newsgroups: comp.infosystems.www.authoring.html >> The problem with charset UTF-8 on pages with forms for e.g. >> guestbooks, formmail and...
34
6356
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
3
6936
by: David Merrick | last post by:
Hi ! can any of you help ? Since datasheets and forms can happily display calculated fields over 255 characters long, I was surprised to discover that the same when read via a DAO recordset...
2
2028
by: Amrit Kohli | last post by:
Hello. I have the following code, to do a simple operation by copying the elements of a vector of strings into an array of char pointers. However, when I run this code, the first element in the...
2
1056
by: Fred | last post by:
hi, suddenly 1 of my ascx is displayed w/ some ureadable characters on all the pages its used - the http send to browser is UTF-8, all others controls work as usual, i haven`t edited any of them...
2
1937
by: Benjamin Johnston | last post by:
Hi, I've found lots of discussion about the JavaScript garbage collector, but no clear answer to this question: Is the garbage collection algorithm used in JavaScript on ASP based on...
15
2362
by: vk02720 | last post by:
Hi, I am trying to implement garbage collection for C/C++ mainly for learning purpose. I dont know where to start. For example - Basic questions - How do I identify the variables that contain...
12
9541
by: leonard.guillaume | last post by:
Hi guys, I use dynamic char arrays and I'm trying to get rid of the garbage in it. Let me show you the code and then I'll explain more in details. ...
10
1921
by: Lawrence Krubner | last post by:
Once upon a time, there were no garbage characters on this page: http://www.teamlalala.com/blog/category/css/ Now there are. For instance: The 2nd paragraph from page 114 of “The Zen Of...
0
7105
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,...
0
6967
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...
0
7132
Oralloy
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,...
1
6846
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...
0
7341
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...
0
5439
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,...
0
4564
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...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
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 ...

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.