String is automatically getting truncated

R

R.Manikandan

Hi

In my code, one string variable is subjected to contain more amount of
characters. If it cross certain limit, the string content in the
varabile is automatically getting truncated and i am not getting the
full data.

Is there any max limit for an variable to store in javascript?

Can anyone please help me to solve this prob?
 
R

Richard Cornford

R.Manikandan said:
In my code, one string variable is subjected to contain
more amount of characters. If it cross certain limit, the
string content in the varabile is automatically getting
truncated and i am not getting the full data.

At least that is the interpretation you are placing on the evidence that
you are keeping to yourself.
Is there any max limit for an variable to store in
javascript?

For string primitives no practical limit less than OS available memory
has been identified. No restrictions are stated in the specification.
Can anyone please help me to solve this prob?

Probably, but not without information.

Richard.
 
R

R.Manikandan

Richard said:
At least that is the interpretation you are placing on the evidence that
you are keeping to yourself.


For string primitives no practical limit less than OS available memory
has been identified. No restrictions are stated in the specification.


Probably, but not without information.

Richard.

Richard,

Sorry. I didnt express the issue properly.

I am getting the data from database in php and generating a combo box
by using it, which i got thourgh ajax in my code. I am using xml based
response and the variable used to get the child node value is not
capable of holding all the content and it is getting truncated.

Here is my code...

response = http_request.responseXML;
var items = response.getElementsByTagName("movienames");
if(items!=null && items.length!=0)
{
for(var i=0; i<items.length; i++) {
mvnamestr =
items.getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue;
mvnameid =
items.getElementsByTagName("mvnameid")[0].childNodes[0].nodeValue;
theanamestr =
items.getElementsByTagName("theatrenamestr")[0].childNodes[0].nodeValue;
theaidstr =
items.getElementsByTagName("theatreidstr")[0].childNodes[0].nodeValue;
}

The
"items.getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue"
itself is not holding the entire content, but the variable what i am
passing from php is having the full data.

So automatically my variable "mvnamestr" wont have the full data.

I request to kindly teach me, if i haven't expressed the issue propely.
 
R

Richard Cornford

Sorry. I didnt express the issue properly.

I am getting the data from database in php and generating a
combo box by using it, which i got thourgh ajax in my code.
I am using xml based response and the variable used to get
the child node value is not capable of holding all the content
and it is getting truncated.
mvnamestr =
items.getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue;

"items.getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue"
itself is not holding the entire content, but the variable what i am
passing from php is having the full data.

<snip>

So your issue has nothing what so ever to do with string variables but
is instead about the capacity of text nodes in an XML DOM.
Mozilla/Firefox/Gecko XML DOMs do have a capacity limit on the text
nodes, but they do represent all of the data in the XML source by
splitting it across multiple text nodes. So the rest of your data is in
childNodes 1 to N.

You either need to loop through the text node children of an element
and accumulate all the data into a string, or possibly call the -
normalise - method of the element so that adjacent text nodes are
amalgamated.

Richard.
 
R

R.Manikandan

Richard,

Thnks a lot. I am having some more doubts in the following code:

response = http_request.responseXML;
var items = response.getElementsByTagName("movienames");
if(items!=null && items.length!=0)
{
for(var i=0; i< items.length; i++) {
mvnamestr =
items.getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue;
mvnameid =
items.getElementsByTagName("mvnameid")[0].childNodes[0].nodeValue;
theanamestr =
items.getElementsByTagName("theatrenamestr")[0].childNodes[0].nodeValue;
theaidstr =
items.getElementsByTagName("theatreidstr")[0].childNodes[0].nodeValue;
}
}

I used the above code [ got from Google ] to parse the xml doc.

When i alert the variable "items.length", i am getting 1 as output in
mozilla, but 0 ( zero ) in IE...dont knw the reason for this..

Can you explain why this happens?

Can you give me some notes regarding how to parse the xml document and
what are the things to be taken care while doing these type of code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top