Why does Google prepend while(1); to their JSON responses?

Why does Google prepend while(1); to their (private) JSON responses? For example, here’s a response while turning a calendar on and off in Google Calendar: while (1); [ [‘u’, [ [‘smsSentFlag’, ‘false’], [‘hideInvitations’, ‘false’], [‘remindOnRespondedEventsOnly’, ‘true’], [‘hideInvitations_remindOnRespondedEventsOnly’, ‘false_true’], [‘Calendar ID stripped for privacy’, ‘false’], [‘smsVerifiedFlag’, ‘true’] ]] ] I would assume this is to prevent … Read more

Best way to end WordPress ajax request and why?

Considering regular WordPress ajax requests like these: add_action( ‘wp_ajax_merrychristmas_happynewyear’, array( $this, ‘merrychristmas_happynewyear’ ) ); add_action( ‘wp_ajax_nopriv_merrychristmas_happynewyear’, array( $this, ‘merrychristmas_happynewyear’ ) ); Will it be best to end function merrychristmas_happynewyear with die(), die(0), wp_die(), or something else and why? 8 Using wp_die() is the best of those options. As others have noted, there are many reasons … Read more

Ajax call always returns 0

I have a problem with AJAX returning 0 always! I have done everything by the book and can’t figure out what is wrong? Please help!! Here is my Ajax call: //Pass data through AJAX var amountToConvert = price; jQuery.ajax({ type:”POST”, url: “../../wp-admin/admin-ajax.php”, // our PHP handler file action: “ajaxConversion”, data: { amount: amountToConvert }, success:function(data){ … Read more

How to check if I am in admin-ajax.php?

Right now for my plugin, I am using in_admin() to determine if the user is in the frontend of the site or in the admin area. However, the problem occurs when plugins use admin-ajax.php to process ajax requests. I need a way to register hooks and plugins only when processing admin-ajax.php file or in the … Read more

ajaxurl not defined on front end

I am trying to create a ajaxform on the front side. I am using the code jQuery.ajax( { type: “post”, dataType: “json”, url: ajaxurl, data: formData, success: function(msg){ console.log(msg); } }); for which I am getting error Uncaught ReferenceError: ajaxurl is not definedworklorAjaxBookForm @ ?page_id=2:291onclick @ ?page_id=2:202 While using similar code on the admin backend … Read more

Admin Ajax is returning 0

I am relatively new to jQuery and AJAX in particular. I have a small issue with the return value always being 0, though I think this is actually the success message and it’s not returning anything. I have scoured the Google-verse and I have the die() function on the PHP callback and I believe the … Read more