hi
i'm a new beee.. to ajax and also for forums..
here's my question goes...
i have a php array and i want to access that array in my ajax script...
how can i access the above mentioned php array in my script..
ajaxusing php arrays in ajax
Page 1 of 1
4 Replies - 698 Views - Last Post: 07 August 2008 - 03:27 AM
Replies To: ajax
#2
Re: ajax
Posted 05 August 2008 - 03:54 PM
you can dynamically create Javascript with PHP..i'm not sure if it's what you mean, but you can do something like:
//JS function
function myfunction()
{
url = "<?php echo $url; ?>"
}
#3
Re: ajax
Posted 06 August 2008 - 04:01 AM
thanks jbrace..
but what i'm trying is i've a php script that will return an array(that holds database values)
i want to use that array in my ajax script ..
is there any way for that..
in short i'll call the php in ajax script and i've to catch that array and then
i have to fill the contents of array in textfields of my html page
but what i'm trying is i've a php script that will return an array(that holds database values)
i want to use that array in my ajax script ..
is there any way for that..
in short i'll call the php in ajax script and i've to catch that array and then
i have to fill the contents of array in textfields of my html page
This post has been edited by kummu4help: 06 August 2008 - 04:04 AM
#4
Re: ajax
Posted 06 August 2008 - 08:52 AM
You can't pass the actual variables from php running on the server to javascript running on the clients browser. What you can do, is have ajax request the php page, have php print the variables in some format (such as xml), and then have the javascript parse the xml and load it into its own arrays.
Javascript has very good support for parsing XML. From http://javascript.ab...ry/blajax12.htm
Javascript has very good support for parsing XML. From http://javascript.ab...ry/blajax12.htm
Quote
For example if we are exmecting a number of entries inside <price> </price> tags in the XML then we can extract them into a Javascript array using:
var xmlDoc = request.responseXML;
var priceArray = xmlDoc.getElementsByTagName('price');
#5
Re: ajax
Posted 07 August 2008 - 03:27 AM
Thanks mocker for ur help....
today i saw the same solution in some website during my googling...
thanks again and can u point me to some good xml learning website.
because i don't know xml...
today i saw the same solution in some website during my googling...
thanks again and can u point me to some good xml learning website.
because i don't know xml...
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|