Skip to main content


Showing posts from January, 2014

JSON Jquery Ajax

If use want to trigger ajax on Click   $('.taskStat').live('click',function(){        $.ajax({             type: 'POST',             url: ajax_url+"Members/change_Addtask/"+stat,             success: function(data) {                 var obj=JSON.parse(data);                 if(obj.resp=='true')                 {                     alert("Hello sudhir");                 } else                 {                     alert("Checking Value");                 }             }         });     }); OR $('.taskStat').live('click',function(){        $.ajax({             type: 'POST',             url: ajax_url+"Members/change_Addtask/"+stat,             success: function(data) {                var obj = jQuery.parseJSON(attr);               $.each(obj, function(key, value) {                    alert(key+'is'+value);                                       });        

Validate Month Day Year

Validate drop down month , day , year  User Jquery : var year=$("#year").attr('value');     var month=$("#month").attr('value');     var day=$("#day").attr('value');     var data="year="+year+"&month="+month+"&day="+day;         $.ajax({             type:"get",             url:"<?php echo HTTP_ROOT;?>validate/validDate?"+data,             success: function(resp){                 if(resp=="false"){                                  alert("Success");                 }else{                  alert("False");                 } Php function method function validate()     {         $day=$_GET['day'];         $month=$_GET['month'];         $year=$_GET['year'];         if(is_numeric($day) && is_numeric($month) && is_numeric($year))         {             if($year%4==0)             {

jQuery used in projects

jQuery Used in Projects 1. Get the length of any class     var numItems = $('.video_box').length;     //Here we get the length of video_box class 2. Get the value of first class     var sourcePath = $(".firstLoadThumb").first().val();     //Here we get the first firstLoadThumb class value 3. Splits the text into array     var sourcePath = "lion|dog|cat";     animal = sourcePath.split('|');     console.log(animal[0]);     //It is explode the string into array. Here animal[0] return lion. 4. Load the page by jquery     location.reload(); 5. Datepicker     Open Datepicker on image click     Html code:     <div class="input-append date" id="dp3">         <input type="text" id="datepicker" />         <span class="add-on"><i class="icon-calendar" id="cal2"></i></span>     </div>     javascripr:     $("#dp3").

One update method for all member

Function function admin_update($table=NULL,$id=NULL) {                  $id = convert_uudecode(base64_decode($id));          $status = $this->$table->findById($id);          $data[$table]['id'] = $id;          if($status[$table]['status']=='Inactive')          {              $this->$table->updateAll(array($table.'.status'=>'"Active"'),array($table.'.id'=>$id));          }          else          {              $this->$table->updateAll(array($table.'.status'=>'"Inactive"'),array($table.'.id'=>$id));              $this->$table->updateAll(array($table.'.admin_status'=>'"Inactive"'),array($table.'.id'=>$id));          }         $this->Session->write('success','Status has been updated');         $this->redirect($this->referer());     } CTP <?php $memId = base64_encode(convert_

Jquery Image Validation

1 ) jQuery validator method jQuery.validator.addMethod('img_ext',function(value,element){         if(value=="")         {             return true;         }         //alert(element.files[0].size);         var ext_index=value.lastIndexOf('.');         var ext=value.substring(ext_index+1);         var ext_lcase=ext.toLowerCase();         if(ext_lcase=='jpeg' || ext_lcase=='jpg' || ext_lcase=='png' || ext_lcase=='gif')         {             return true;         } else {             return false;         } }, "Please select valid image file" ); Html <input name="logo_image1" type="file"  class="required img_ext" id="logo"> 2)  $('#addAlbum').validate({             ignoreTitle: true,                 rules: {                         "image":                         {                             required: true,