Пустой запрос GET после создания ajax ⇐ Jquery
-
Anonymous
Пустой запрос GET после создания ajax
I'm infant new to jquery and ajax. I think I followed how to build an ajax request pretty good, removing json dataType params succeeds but I'm getting an empty response out of it. I tried dumping whatever's inside my $_GET but I got nothing, the array's still empty, help?
function ajax_statLocale(sabaw) { let limiter = { 'totalCost':'Cost in total', 'totalItems':'Total stocks registered', 'totalCategories':'Total of distinct categories', 'totalManufacturers':'Total of distinct manufacturers', 'totalDistributors':'Total of distinct distributors' }; if (Object.keys(limiter).includes(sabaw)) { //AJAX $.ajax({ url: './core/classes/datareadable.class.php', type: 'GET', dataType: 'json', data: { test : 'I cannot send this test' }, success: function(data, xhr) { console.log("succees!: " + data); }, done: function() { console.log('okay'); }, error: function(jqXHR, textStatus, errorThrown) { console.log("AJAX request failed."); console.log("jqXHR: " + jqXHR); console.log("textStatus: " + textStatus); console.log("errorThrown: " + errorThrown); } }); } else { console.log('Cannot execute request'); } } I've seen others solve this same issue but their solutions aren't working for me, for some reason.
Источник: https://stackoverflow.com/questions/780 ... lding-ajax
I'm infant new to jquery and ajax. I think I followed how to build an ajax request pretty good, removing json dataType params succeeds but I'm getting an empty response out of it. I tried dumping whatever's inside my $_GET but I got nothing, the array's still empty, help?
function ajax_statLocale(sabaw) { let limiter = { 'totalCost':'Cost in total', 'totalItems':'Total stocks registered', 'totalCategories':'Total of distinct categories', 'totalManufacturers':'Total of distinct manufacturers', 'totalDistributors':'Total of distinct distributors' }; if (Object.keys(limiter).includes(sabaw)) { //AJAX $.ajax({ url: './core/classes/datareadable.class.php', type: 'GET', dataType: 'json', data: { test : 'I cannot send this test' }, success: function(data, xhr) { console.log("succees!: " + data); }, done: function() { console.log('okay'); }, error: function(jqXHR, textStatus, errorThrown) { console.log("AJAX request failed."); console.log("jqXHR: " + jqXHR); console.log("textStatus: " + textStatus); console.log("errorThrown: " + errorThrown); } }); } else { console.log('Cannot execute request'); } } I've seen others solve this same issue but their solutions aren't working for me, for some reason.
Источник: https://stackoverflow.com/questions/780 ... lding-ajax
Мобильная версия