Page 1 of 1

JSON VS Javascript array

Posted: Mon Jun 05, 2006 1:42 am
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

Posted: Mon Jun 05, 2006 1:48 am
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?

Posted: Mon Jun 05, 2006 3:36 am
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? :)

Thanks Everah

Posted: Mon Jun 05, 2006 3:47 am
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

Re: Thanks Everah

Posted: Mon Jun 05, 2006 4:03 am
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 ;)

Re: Thanks Everah

Posted: Mon Jun 05, 2006 4:09 am
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...

Re: Thanks Everah

Posted: Mon Jun 05, 2006 5:23 am
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 ;)

Re: Thanks Everah

Posted: Mon Jun 05, 2006 7:05 am
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

Posted: Mon Jun 05, 2006 8:29 am
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.

Thanks Everah ! thanks once again...

Posted: Tue Jun 06, 2006 12:37 am
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..

Posted: Sat Jun 10, 2006 7:43 am
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.

Posted: Wed Jun 14, 2006 3:49 am
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..

Posted: Thu Jul 20, 2006 9:24 pm
by jetbrains
I think javascript array is also a good choice, please go to the URL
http://www.developerzone.biz/index.php? ... &Itemid=45