I have an AJAX function in WordPress that calls a PHP function to return a transition entry value to a database.
When I call a function using jQuery, I get the result, but always has an extra 0 (zero) added to the value.
Here is my jQuery function:
(function($) { $(document).ready( function() { var AdvancedDashboardWidget = function(element, options) { var ele = $(element); var settings = $.extend({ action: '', service: '', countof: '', query: '', callback:'' }, options || {}); this.count=0; var url=''; switch(settings.service) { case 'facebook': if(settings.countof=='likes' || settings.countof=='talks') { ajaxCall(action,ele,settings); } } }; var ajaxCall = function(action,ele,settings){ opts = { url: ajaxurl,
There are more helper functions, but this is the main jQuery function, which communicates with WordPress and returns the value of the PHP function.
The problem is that if the value is returned as " 99 ", for example, it will be returned as " 990 "
Here is the PHP function that jQuery calls:
public function get_facebook_likes(){ echo 99; }
If I change the above to return 99; I get a simple 0
Jason source share