By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

String is automatically getting truncated

P: n/a
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?

--
Mani

Aug 28 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
R.Manikandan wrote:
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.
Aug 28 '06 #2

P: n/a
Richard Cornford wrote:
R.Manikandan wrote:
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.
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[i].getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue;
mvnameid =
items[i].getElementsByTagName("mvnameid")[0].childNodes[0].nodeValue;
theanamestr =
items[i].getElementsByTagName("theatrenamestr")[0].childNodes[0].nodeValue;
theaidstr =
items[i].getElementsByTagName("theatreidstr")[0].childNodes[0].nodeValue;
}

The
"items[i].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.

--
Mani

Aug 29 '06 #3

P: n/a
R.Manikandan wrote:
Richard Cornford wrote:
>R.Manikandan wrote:
>>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.
<snip>
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.
<snip>
mvnamestr =
items[i].getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue;
<snip>
"items[i].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.

Aug 29 '06 #4

P: n/a

Richard Cornford wrote:
R.Manikandan wrote:
Richard Cornford wrote:
R.Manikandan wrote:
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.
<snip>
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.
<snip>
mvnamestr =
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[i].getElementsByTagName("mvnamestr")[0].childNodes[0].nodeValue;
mvnameid =
items[i].getElementsByTagName("mvnameid")[0].childNodes[0].nodeValue;
theanamestr =
items[i].getElementsByTagName("theatrenamestr")[0].childNodes[0].nodeValue;
theaidstr =
items[i].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?

--
Mani

Aug 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.