Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > php to javascript array

Reply
Thread Tools

php to javascript array

 
 
turnitup
Guest
Posts: n/a
 
      09-13-2006
Dear all,

I have a JavaScript function that talks to php using ajax. It can return
values from php.

Up until now, I have used it to return simple values such as integers or
text strings.

However, I wish now to return an array. Is it possible to create an
array in php, format it in some way and pass it back to javascript for use?

TIA

Steve
 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      09-13-2006

turnitup wrote:
> Is it possible to create an
> array in php, format it in some way and pass it back to javascript for use?


IMHO that would be much easier achieved by using JSON (see
http://www.json.org, it also includes ready to use client-side script
module and server-side bearers in PHP).

 
Reply With Quote
 
 
 
 
Sawi
Guest
Posts: n/a
 
      09-13-2006
turnitup napisaƂ(a):
> using ajax.


> to return simple values such as integers or
> text strings.
>
> However, I wish now to return an array. Is it possible to create an
> array in php, format it in some way and pass it back to javascript for use?


First:
If You say - AJAX - you mean Asynchronous JavaScript and *XML* - so You
should use XML. You don't use AJAX
Second:
Find in google "JSON" - it help You in this problem.

--
Pozdrawiam,
Sawi
www.fruitysite.net
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      09-13-2006


turnitup wrote:


> I have a JavaScript function that talks to php using ajax. It can return
> values from php.


> However, I wish now to return an array. Is it possible to create an
> array in php, format it in some way and pass it back to javascript for use?


There are various data interchange formats possible, one is JSON, which
in terms of JavaScript is just a subset for what JavaScript allows
syntactically for object and array literals, and which has lots of
libraries for other languages, one being PHP, see the "JSON in PHP"
entry on <http://www.json.org/>.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
turnitup
Guest
Posts: n/a
 
      09-15-2006
turnitup wrote:
> Dear all,
>
> I have a JavaScript function that talks to php using ajax. It can return
> values from php.
>
> Up until now, I have used it to return simple values such as integers or
> text strings.
>
> However, I wish now to return an array. Is it possible to create an
> array in php, format it in some way and pass it back to javascript for use?
>
> TIA
>
> Steve


Thank you everyone for your replies. Looks like JSON for now.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
Validate your html forms with javascript and php with a simple php class __ Javascript 1 10-02-2007 11:06 AM
Writing a PHP and Javascript generated page to a PHP variable... jonnyblazed@gmail.com Javascript 3 09-04-2006 12:45 PM
How is a PHP (.php) or JavaScript web site spidered by search engines? eastcoastguyz Javascript 1 07-11-2006 03:52 AM
php array in javascript function Obscurr Javascript 1 10-20-2003 10:10 AM



Advertisments