Form.submit() submits to blank page
- var checkStock = function(){
var validated = false;
$("form").submit(function(e){
e.preventDefault();
var form = $(this); // <- here i cached $(this) so we can use it later.
var data = true;
if (!validated) {
/* var naam =$('#inputString').val();
if(naam == ""){
$('#alert2').html('Gelieve naam in te vullen');
$('#alert2').css({'background-color' : 'red', 'color' : 'white'}).show();
$('#alert2').show();
data = false;
}else{
$('#alert2').hide();
data = true;
}*/
$.getJSON("../js/producten.js", function(json) {
$('.item-row').each(function() {
var code = $(this).find(".code").val();
var qty = $(this).find(".qty").val();
if(code != "" && qty != 0){
// door het fileke loopen producten.js
$.each(json.channel.items,function(i,item) {
// als het item in de array items[i] overeenkomt met de naam dat ik opgeef
if(json.channel.items[i].code == code) {
aantalBesteld = parseInt(qty);
ItemsInStock = parseInt(json.channel.items[i].instock);
ItemsLeft = ItemsInStock - aantalBesteld;
if(ItemsInStock < aantalBesteld ){
alert("stock kleiner dan bestelling");
data = false;
}
}
}); // end each json
}// if code en qty
}); // end each item-row
if (data) {
validated = true;
$("form").submit();
//$form[0].submit();
}
});// end getjson
return false;
} else {
return true;
}
});
};
as you can see it retrieves data with json so it makes an invoice. If the items that er in stock are smaller then the items that are ordered the paga can not be send.
This part works BUT
if everthing is ok and we get to our submit, it submits but goes to a white/blank page ?
any ideas? i tried everything i could think of, no luck, even in the IRC no luck.
live example:
http://hablahabla.be/kassa/welcome/loadfactuur