Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Robert Walker
17,146 PointsAJAX returning 200 but no response from PHP code
if($_GET['email'] && $_GET['new_email']){
// tried also header("location: " . WWW . "index.php");
echo 'hello';
$p = 5;
echo $p;
// wont work if I change GET to POST
}
$("#changeE_form").submit(function(e) {
var url = "<?= WWW ?>email.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#changeE_form").serialize(), // serializes the form's elements.
}).done(function(resp) {
alert(resp);
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
Request Method:POST Status Code:200 OK
<form action="<?= WWW ?>email.php" name="changeE_form" id="changeE_form" method="post">
<input type="email" name="email" placeholder="Email" required>
<input type="email" name="new_email" placeholder="New Email" required>
<input type="submit" value="Change Email">
</form>
Tried a lot of different suggestion on stack but nothing is working so far.
huckleberry
14,636 Pointssorry brother but I have zero experience with PHP sooooo ... yeah.
Cheers,
Huck -
Robert Walker
17,146 PointsRobert Walker
17,146 PointsNot sure what is happening but if I change my php code to a post I get internal server error and if I use GET it works fine but no response.
Its so strange.