I have a small problem loading a php function if(isset... to a page where is form with onsubmit function :
function functionlol() {
$('#phptestlol').load('system/phptest.php');
}
Now, the phptest.php contains this :
if(isset($_POST['test'])){
echo "Working with submission also";
}
echo "Working";
and html with form looks like this:
<span id='phptestlol'></span>
<form method='POST' onsubmit='functionlol()' target='test'>
<input type='submit' name='test' value='Submit'>
</form>
I did target='test' because I don't want page to be refreshed. When I click the submit button, it loads the php file, but it shows only the "Working" echo, and doesn't echo that "Working with submission also"... what am i supposed to do to make it work? Thanks!
EDIT WHOLE HTML:
<html>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script>
$('form').submit(function(event) {
event.preventDefault();
$('#phptestlol').load('system/phptest.php', {test:1});
});
</script>
</head>
<body>
<iframe name='test' style='display:none;'></iframe>
<span id='phptestlol'></span>
<form method='POST' target='test'>
<input type='submit' name='test' value='Submit'>
</form>
</body>
</html>
PHP (phptest.php):
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
if(isset($_POST['test'])){
echo "submitted";
}
?>