Answer the question
In order to leave comments, you need to log in
Why might Ajax not work?
Help me figure out what's the problem?
I'm trying to call a php script via ajax, after inserting the resulting array back into html, but something went wrong.
JS
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('#form').submit(function(e){
e.preventDefault();
var data = $(this).serialize();
$.ajax({
type: "POST",
url: "new.php",
data: data,
success: function(result){
$('#result').html(result);
}
});
});
});
</script>
<form id="form">
<input type="text" name="text">
<input type="submit">
</form>
<div id="result">
</div>
var_dump($_POST);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question