Monday, April 16, 2012

ajax background process after submit button

the script I post works fine, it just execute in background my php code at the load of the page.. What I cannot do is to start the php in background after having pressed a submit button.. I tried to add a form in the body but I don't know how to link it with the ajax.. how could be done?
thanks!



<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url: 'trial.php',
beforeSend: function() {
// you could also put a spinner img or whatever here too..
$("#myStatusDiv").html("started..");
},
success: function(result) {
$("#myStatusDiv").html(result);
}
});
});
</script>

</head>
<body>

</body>

</body>
</html>




1 comment: