php - In AJAX, do I have to init the class? -


i trying out page refresh (but think way going it, require page refresh. ultimate goal not have one.

i have 2 things wrong, 1 basic html, other not understanding ajax.

html issue

when click link beside element:

<label class="checkbox">     <input type="checkbox" name="aisis_options[package_aisis-related-posts-package-master]"      value="package_aisis-related-posts-package-master" checked="">          aisis-related-posts-package-master <a href="#">(disable)</a> </label> 

it executes piece of js:

(function($){        $(document).ready(function(){         $('a').click(function(){           var el = $(this).prev('input[type="checkbox"]');           if(el.is(':checked')){                el.prop('checked',false);              }         });     });   })(jquery); 

unchecks it, page refreshes , scrolls top. assuming there js way stop or maybe stupidity of having "#" in <a href=""> part?

ajax issue

i don't understand ajax @ all, aside passing information client server, added following above js:

(function($){        $(document).ready(function(){         $('a').click(function(){           var el = $(this).prev('input[type="checkbox"]');           if(el.is(':checked')){                el.prop('checked',false);              }           $.ajax({               url  : <?php coretheme_admin_template_helper . 'uncheckpackagethemehelper.php';?>,               type : 'get',               data : { 'element_name' : el.prop('name') }                  });         });     });   })(jquery); 

then wrote following class:

class coretheme_adminpanel_template_helper_uncheckpackagethemehelper{      private $_element_name = null;      public function __construct(){          if(isset($_get['element_name'])){             $this->_element_name = $_get['element_name'];             echo $this->_element_name;         }     } } 

essentially see element_name echoes when click disable link next checkbox of checked object - out page refresh if possible.

my issue is, not understanding if have done right, aside java script uncheck element which got answer question.

please help, idea is: click disable, disable checkbox, echo element name passing php - out page refresh if possible.

update

this class never instantiated. ever. where. idea click, want click disable, have pass element name class , class echo variable out page refresh...

html issue: arun said use e.preventdefault() prevent default click action.

ajax issue: noticed haven't echoed url. change

<?php coretheme_admin_template_helper . 'uncheckpackagethemehelper.php';?> 

to

<?php echo coretheme_admin_template_helper . 'uncheckpackagethemehelper.php';?> 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -