Ajax + php passing parameter as array

I am building a web application in Ajax + Php.
Using Ajax, i would like to pass a javascript array containing some form values to a php script.
The script php then should get the array and access the array data.
But I cant get it working :p
I think I am doing something wrong in my js function...

Here is my form:
[code]
var p = new Array()

Search Content:

in

<? $misc->getSelectCategory(); ?> //fetch data in the db and build the select list


[/code]

Here is my control function in my ajax.js
[code]
function control(p,action)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url= "include/"+ action +".php"
url=url+"?p[]="+p
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
[/code]

And in my content_get2.php: $p = $_GET["p"];
Since I send my url+"?p[]="+p, i get an array, but its empty...
What do i do wrong?

Please help me!

Comments

  • I recommend http://script.aculo.us/downloads for ajax requests

    usage is much easier

    [code]
    function request()
    {new Ajax.Request('usethesamepage.php', { method: 'get', parameters: { req: $('formname').serialize()}, onSuccess: function(p)
    {alert(p.responseText);}})}
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion