Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So I was doing a lot of things wrong. But this is the only way it works, for me - please post your comments if you have better solution.</p> <p>In the class, I have to do this:</p> <pre><code>class CoreTheme_AdminPanel_Template_Helper_UncheckPackageThemeHelper{ private $_element_name = null; public function __construct(){ if(isset($_GET["element_name"])){ $this-&gt;_element_name = $_GET["element_name"]; echo json_encode($this-&gt;_element_name); } } } new CoreTheme_AdminPanel_Template_Helper_UncheckPackageThemeHelper(); </code></pre> <p>The class <strong>cannot</strong> be instantiated in the .phtml file with the resulting Ajax or the request is never sent back. Also notice the <code>json_encode</code> You cannot pass regular variables back to Ajax - when in a class (I think) - How ever when not in a class it seems to work - clarification is needed.</p> <p>The Ajax then looks like this:</p> <pre><code>(function($){ $(document).ready(function(){ $('a').click(function(e){ var el = $(this).prev('input[type="checkbox"]'); if(el.is(':checked')){ el.prop('checked',false); } $.ajax({ url : "http://localhost/wordpress/wp-content/themes/Aisis-Framework/CoreTheme/AdminPanel/Template/Helper/UncheckPackageThemeHelper.php", type : 'GET', data : { 'element_name' : el.prop('name') }, success: function(data, textStatus, jqXHR){ console.log(data); }, error: function(jqXHR, textStatus, errorThrown ){ console.log(jqXHR, textStatus, errorThrown); } }); e.preventDefault(); }); }); })(jQuery); </code></pre> <p>The Data that comes back is what I expect: <code>"aisis_options[package_RelatedPosts]"</code> </p> <p>There ar a couple of issues with this answer - One I dont understand why I have to instantiate the class inside the file its written in, and two not sure why I have to encode the response in a class, but not when its just a "script kiddy" file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload