Reputation: 101
<form action="form.php">
<input type="text" name="email">
<input type="text" name="pass">
<input type="submit">
</form>
<script src="jquery.js"></script>
<script>
$("form").on("submit",function() {
$.ajax({
url: 'http://somewhere.org/login.php',
type: 'GET',
data: 'Data written to File',
success:function(response){}});
});
</script>
Ok heres the problem, i tried this code on opera it runs the scripts and the form's action, a success.. But on Qwebview it runs only the scripts but not the form, Why is that? I tried commenting out the scripts but the form still doesn't work.
Upvotes: 1
Views: 316
Reputation: 9754
Your form with ajax requires return false;
In $.ajax
use error
event for get errors.
Example:
$("form").on("submit",function() {
$.ajax({
url: 'http://somewhere.org/login.php',
type: 'GET',
data: 'Data written to File',
success:function(response){
//Something...
},
error:function(a, b, c){
alert([a, b, c]);//Get error
}
});
return false; //Prevent reload page
});
Upvotes: 1