I have a form that needs to run a php script once the submit button is clicked, it needs to be ajax.
<form method="post" action="index.php" id="entryform" name="entryform">
<input type="submit" name="submit" value="Submit" onclick="JavaScript:xmlhttpPost('/web/ee_web/include/email-notification.php', 'entryform')" />
</form>
In this situation, using if(form posted) { get results and run script } is not an option, I need to run the script externally, that is why I need it to execute the email-notification.php at onclick
When I point my web browser to domain.com/include/email-notification.php – it runs perfectly.
Any help is appreciated.
This executes the script before you submit the form, now I need to wait to execute the script once the submit button is clicked, possible to do this?
$.ajax({
type: "POST",
url: "/include/email-notification.php",
dataType: "script"
});
Check out the $.ajax() function of the jQuery javascript library. It will make you life much much easier and is quite minimal as far as added size to your page (like 12kb or something like that).