Tuesday, 28 August 2018
Subscribe to:
Post Comments (Atom)
php
script using AJAX
. However I am running into an issue with actually passing the data across. The $_POST
array is empty for some reason.HTML
is:<form>
<label>Email Address:</label>
<input type='text' name='email' value='jackc@test.com'/>
<input type='submit' name='submit' value='Check subscription status'/>
</form>
JQuery
is: $(document).ready(function() {
$('form').submit(function(e){
e.preventDefault();
var url = 'request.php';
$.ajax({
type: 'POST',
url: url,
contentType: "json",
data: $('form').serialize(),
success: function(data){
console.log(data);
$('#results').html(data);
}
});
});
});
PHP
is: $emailAddress = $_POST['email'];
echo "EMAIL: " . $emailAddress;
$('form').serialize()
I see email=jackc%40@test.com
which I would expect to see returned from my PHP
.Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment