In order to refresh the classes on the
<body>element after an AJAX call, I am writing at the top of my AJAX response the following in JSON:
$o[ 'classes' ] = get_body_class('project');
I can then see in the JSON response the following:
What I am trying to do is to put all those classes into the body using jQuery in order to "refresh" them and transfer the informations regarding the classes of the current template loaded in AJAX.
var thecontent_classes = data.classes; //alert(thecontent_classes); $('body').removeClass(); $('body').addClass(thecontent_classes);
With the previous code, it is unfortunately not working because it is adding the JSON list with all the classes separated by comas if I'm testing the content of the variable with an alert. I tried to replace the comas by spaces using str.replace without success... Maybe there is an easier way, either with the PHP side or with the str replace ??
Thank you for your time and help.