in my php script at the top i have require_once('../registration/include/membersite_config.php'); wich is a class with all my site functions. This class is called fgmembersite. There is a function inside that i normaly call with $fgmembersite->stats but now i have to call it from a jquery function.
In the same php script i have this jquery code:
$('a.slick-toggle').click(function(){
var the_id = $(this).attr('href');
var div_id = $('#job_' + the_id);
if ($(div_id).is(":visible")==false) {
//Here i will put the AJAX CALL
}
$(div_id).toggle(400);
return false;
});
I want to call the stats() function form the jquery code when my condition is trigered, but this function is inside a class wich is already loaded with the requiere_once from the top.
Normaly when i make an ajax call i pass the parameters via POST to a function writen in other php file using for example: $.ajax({ url: 'addremovelive.php', data: {addname: val,addlevel: val1}, type: 'post',success: function(d) {$('#add_lang_level').val('');$('#add_lang').val('');}});
Using that method means that i will have to change my struture in the class in order to respond to a post call. There is another method to call my function using jquery/ajax?
Thanks for any orientation!
You can’t call methods/functions or anything from jquery directly.
But what you can do is trigger only the required method with a post/get variable from jquery. Means you have to add as you did before a post call to the file with the functions and yes – change the method so that it gets triggered as soon as a certain post/get variable is included in the call.