Title: Submit multiple rows to php url with one submit
Post by: tooletime on March 15, 2016, 09:13:03 AM
I have a datagrid that i want to submit all the rows to a php url and i can get it to submit but it asks the success for each one i submit. i know im missing something easy. Here is my code. function getCart() { var ids = []; var titles = []; var descritptions = []; var output = ""; var rows = $('#cart').datagrid('getRows'); var emailfrom = $('#emailfrom').val(); var datastring = "ID=" + rows[i].ID + "&copies=" + rows[i].copies + "&emailfrom=" + emailfrom +""; for (var i = 0; i < rows.length; i++) { $.ajax({ type: "POST", url:"echo.php", data:datastring, cache: false, success: function(result) { $.messager.confirm('Confirm','Are you sure you want to Submit cart?', function (r) { if (r) { $.messager.show({ title:'Job Submitted', msg:'Thank you for your job submittal.', timeout:5000, showType:'slide' }); //messager.show setTimeout( function() {location.reload(); }, 5000); } else { return false; } }); } });
}
Title: Re: Submit multiple rows to php url with one submit
Post by: tooletime on March 15, 2016, 03:35:32 PM
i figured it out and this is how im doing it. function getCart() { var emailfrom = $('#emailfrom').val(); var rows = $('#cart').datagrid('getRows'); var data = {}; var grid = $('#cart'); var rows = grid.datagrid('getRows'); $.messager.confirm('Confirm','Are you sure you want to Submit cart?', function (r) { if (r) { for (i=0; i< rows.length; i++) { url = "echo.php?ID=" + rows[i].ID + "&copies=" + rows[i].copies + " + &emailfrom=" + emailfrom +""; $.post(url); } $.messager.show( { title:'Job Submitted', msg:'Thank you for your job submittal.', timeout:5000, showType:'slide' }); //messager.show setTimeout( function() {location.reload(); }, 5000); } else { return false; } }); }
|