JSON VS Javascript array

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
shrikant_deshpande
Forum Newbie
Posts: 8
Joined: Sat May 27, 2006 1:40 am

JSON VS Javascript array

Post by shrikant_deshpande »

Hello guys,

Can you please tell me who will be faster Json or Javascript array?
I have list of members (nearly 4000) .. I have to show them in combo dynamically...
Should I use JSON data or Java array?
Please guys help me out...

thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

This seems like it would best fit in the Client Side forum, seeing as you are choosing between JSON and JS.

On a side note, can you test thest to see which would be faster? Also, since you are generating a dynamic select list, why not generate it server-side using PHP?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I think JSON will be faster. JavaScript (in most engines) manages memory for arrays extremely badly. Maybe it does for objects too (although heck if it does... the whole language is OO 8O).

But yeah, why not generate the list server side? :)
shrikant_deshpande
Forum Newbie
Posts: 8
Joined: Sat May 27, 2006 1:40 am

Thanks Everah

Post by shrikant_deshpande »

Everah wrote:This seems like it would best fit in the Client Side forum, seeing as you are choosing between JSON and JS.

On a side note, can you test thest to see which would be faster? Also, since you are generating a dynamic select list, why not generate it server-side using PHP?
Thanks Everah !

Thanks for helping me...
Actually let me tell you what is my problem...
I am using smarty template engine... and on the template page I have to show Autocomplete textbox for nearly 4000 members... So for this purpose I am using javascript... I am creating array of all the members....
(like gmail system)... So instead of using javaarray should I use JSON data...?
If you the answer please tell me...

Thanks once again
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Thanks Everah

Post by Chris Corbyn »

Gmail uses AJAX. I wouldn't attempt an Aut-Complete feature in JavaScript with over 4000 array members.

Look into doing this with a hybrid of server-client technology using AJAX ;)
shrikant_deshpande
Forum Newbie
Posts: 8
Joined: Sat May 27, 2006 1:40 am

Re: Thanks Everah

Post by shrikant_deshpande »

d11wtq wrote:Gmail uses AJAX. I wouldn't attempt an Aut-Complete feature in JavaScript with over 4000 array members.

Look into doing this with a hybrid of server-client technology using AJAX ;)
Thanks d11wtq !!!

Thanks for your help... But I am using smarty templates.. .. Do you think that it will work perfectly in case of templates...?

Thanks for feedback again...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Thanks Everah

Post by Chris Corbyn »

shrikant_deshpande wrote:
d11wtq wrote:Gmail uses AJAX. I wouldn't attempt an Aut-Complete feature in JavaScript with over 4000 array members.

Look into doing this with a hybrid of server-client technology using AJAX ;)
Thanks d11wtq !!!

Thanks for your help... But I am using smarty templates.. .. Do you think that it will work perfectly in case of templates...?

Thanks for feedback again...
I don't see why not, the template is parsed server-side. AJAX still does all of that stuff... it just does it behind the scenes ;)
shrikant_deshpande
Forum Newbie
Posts: 8
Joined: Sat May 27, 2006 1:40 am

Re: Thanks Everah

Post by shrikant_deshpande »

shrikant_deshpande wrote:
Everah wrote:This seems like it would best fit in the Client Side forum, seeing as you are choosing between JSON and JS.

On a side note, can you test thest to see which would be faster? Also, since you are generating a dynamic select list, why not generate it server-side using PHP?
Thanks Everah !

Thanks for helping me...
Actually let me tell you what is my problem...
I am using smarty template engine... and on the template page I have to show Autocomplete textbox for nearly 4000 members... So for this purpose I am using javascript... I am creating array of all the members....
(like gmail system)... So instead of using javaarray should I use JSON data...?
If you the answer please tell me...

Thanks once again
Everah thanks for your reply..

Thanks for your clarification...
I have found a nice solution for my problem...
Please go to this url = http://www.dhtmlgoodies.com/index.html?page=ajax
Here I have found the autocomplete list...in AJAX...
If you need any help in ajax please review above site...

Thanks bye
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You know, I have code laying around somewhere that was developed by Glenn Vergara. When I find it I will try to post it or a link to it. It is an awesome OO Javascript application that does autocomplete (and a few other things). His site seems to be lost in cyberspace right now, but here is a link to a thread on CodingForums that might be able to help you as well.

I would agree with the other posters here that you really do not want JS running through 4000 records on an autocomplete. Using AJAX you can hit the server after every keystroke to get deeper into your list. Have a look at the Dictionary at Objectgraph.com. That uses AJAX with a .NET/SQL Server backend, but can be easily adaptd to suit your needs.
shrikant_deshpande
Forum Newbie
Posts: 8
Joined: Sat May 27, 2006 1:40 am

Thanks Everah ! thanks once again...

Post by shrikant_deshpande »

You are so kind to me... thanks...
Thanks for the links provided... Please tell me something about your self...
We can be good friends.... Also please provide me the list of nice and generous people like you (if you have)...
:D thanks once again..
Li0rE
Forum Commoner
Posts: 41
Joined: Wed Jun 07, 2006 6:26 am

Post by Li0rE »

lol. Why wont you just make a script (a seperate script) that looks up usernames with %LIKE% and use AJAX to keep on posting what's typed up in the form. Not only will you get better results for autocomplete, but it wont be memory intensive at all.
shrikant_deshpande
Forum Newbie
Posts: 8
Joined: Sat May 27, 2006 1:40 am

Post by shrikant_deshpande »

HI Li0rE....

I have used the same coding... I think this is much faster than other scripts...
I have gained some knowledge of ajax just because of this problem..
jetbrains
Forum Newbie
Posts: 6
Joined: Tue Jun 27, 2006 9:08 pm

Post by jetbrains »

I think javascript array is also a good choice, please go to the URL
http://www.developerzone.biz/index.php? ... &Itemid=45
Post Reply