I use PHP to echo back javascript and html. I am trying to send two values to another PHP file using AJAX with the code echoed back from the original echo. An example of this javascript is:
<script>
$(document).ready(function () {
$('#join_testtest').on('cick', function() {
var clubName = $('#join_name_testtest').val();
var userName = $('#userName_join').val();
$.ajax({
url: 'joinClub.php',
method: 'POST',
data: {
clubName: clubName,
userName: userName
},
success: function(response){
$('#response_join').html(response);
},
dataType: 'text'
});
});
});
</script>
Here is the html code that corresponds to the above example:
<input id='join_testtest' type='button' value='join testtest'>
<input type='text' id='join_name_testtest' style='display:none;' value='testtest'>
<input id='userName_join' style='display:none;' value ='1'>
There are no errors in the console. The PHP will either exit with keyword success or fail but nothing is printed in #response_join. Any help is apreciated.