Just a simple question (I think).
Have a look at the code in this fiddle: http://jsfiddle.net/d9wdM/1/
What I doing is creating a website as a personal project that let's the user enter any amount of names and e-mail addresses and once the form is submitted, a random name is selected from the names and an e-mail is sent to that person and also their name is outputted on the page.
I can get the AJAX call to work but I don't know how to pass the name variable back from process.php to index.php as all it can return is a 1.
I hope that makes sense, if it doens't please let me know and I will try and make it clearer.
Thanks again,
Martin
Managed to solve it, changed the ajax call to:
<script type="text/javascript">
$(function() {
$('.tearoundform').submit(function()
{
var query = $(this).serialize();
$('#form_results').fadeOut(500).addClass('ajax-loading');
$.ajax({
type: "GET",
url: "process.php",
data: query,
success: function(data)
{
$('#form_results').removeClass('ajax-loading').html(data).fadeIn(500);
}
});
return false;
});
});
</script>`
In your ajax code your are misssing dataType which means the type of data that you're expecting back from the server.
So in your case you can set dataType as html and render html from server. This will help you.
I'll suggest u one thing if u want something return from ajax page then must use dataType='json'
and use json_encode(array('returnData'=>1))
on process.php
again on index.php u can use json_decode()