- Simple Ajax Program In Php
- Ajax Url Php
- Ajax Php Tutorial
- Simple Ajax Examples In Php
- How To Program In Php
- Php Vs Ajax
AJAX is a developer's dream, because you can: Update a web page without reloading the page Request data from a server - after the page has loaded Receive data from a server - after the page has loaded Send data to a server - in the background.
I'm having a difficult time using AJAX to send an associative array to a php file. There's somethings I'm not understanding clearly. Here's my code to make the array from a form of input tags, but I don't know how to send it and interpret it in php.
Here's my php code:
Ah now everything works. I edited all the code here to make this work.
I also have a div with id=wines . It was another thing I forgot to show. That's where the data is being returned to and displayed without the name however.
4 Answers
Simple Ajax Program In Php
Your jQuery code to collect the values is correct, although .serialize()
will simplify it.
To retrieve the values in PHP, it's the same as if the form were being submitted normally. They're in $_GET['name']
and $_GET['address1']
. theData
is just the name of the Javascript variable containing the object, it's not a property name sent to PHP.
Ajax Url Php
To send data: I'm assuming you want to send the results of your form? To do this, first you're going to need to add a submit button to your page. This should be placed in your form to submit the code.
Ajax Php Tutorial
Second, it looks like you're missing the <div>
which you've referenced in the AJAX success response, so you're going to want to add that.
Simple Ajax Examples In Php
meoww-meoww-Try this you have to add button to your form to fire the action:
Osama JetaweOsama JetaweSorry I'm on my phone so its a short answer but use serialize
Example
Christian