[Solved] jquery ajax have error [closed]

The error would probably be from this being a plain Object rather than the Element. Every function has its own this value, determined when it’s invoked. And, inside of the success callback, this will typically refer to the settings of the request. $.ajax({ // … success: function () { console.log(this.type, this.url); // “POST” “/funfact_ajax” } … Read more

[Solved] display json response from ajax call in html table

You need to iterate on items object as array is insde items object: $.each(json.items,function(index,item){ console.log(item); tr = $(‘<tr/>’); tr.append(“<td><h3>” + item.name + “</h3><p><strong>” + item.productNo + “</strong></p><div>” + item.leaseOrNot + “</div></td>”); tr.append(“<td>” + item.commerceItemQty + “</td>”); tr.append(“<td>” +item.price + “</td>”); $(‘table’).append(tr); }) FIDDLE DEMO 3 solved display json response from ajax call in html table

[Solved] when click on the element, ajax request loaded data in first time, after first time prevent ajax request

Use a flag, check for it and set it to false on complete let shouldAjax = true; // later if (shouldAjax) { $.ajax({ type: “POST”, url: “/php/auth/login.php”, data: $(“#login-form”).serialize(), success: function(msg) { //stuffs }, complete: function() { $(this).data(‘requestRunning’, false); shouldAjax = false; } }); } solved when click on the element, ajax request loaded data … Read more

[Solved] Pass PHP variable to server

First of all, you can’t send arrays directly through GET requests (GET requests are the ones with the parameters visible in the url, in layman terms) therefore, you should do the following: $date = “$year-$month”; //example: 2013-09 $link = admin_url(‘admin-ajax.php?my_date=”.$date.”&post_id=’.$post->ID.’&nonce=”.$nonce); breaking the url down to the components, in layman terms: everything before the ? is … Read more