Feb 16, 2016

How to do start date selected in jquery datepicker using Ajax call

Hey friends sharing information regarding Facing the issues of jQuery date picker object where date not selected by start date in ajax call.

jquery date picker to set start date while in ajax call and getting data from server script. While changing the drop down of course I want to set that course start date in calender view of jquery date picker.Please find below attached screenshotsfor more graphically.

Step 1 : HTML for change start date based on course you have selected. I will show you the below example of slider that need to show images and video where rotate the slider after 3 seconds.




Step 2: Add js and Css of jquery date picker




Step3 : Call server script using Ajax Call as below. You need to remove or distroy the object of datepicker while you change dropdown value.Get date of javascript format from server side script Ex. var d = new Date(2016,02,12); // Javascript date object consider this format.YYYY-MM-DD. From server side script I will crate string as "2016,02,12" which passed into date object of JavaScript.


Step4 : PHP server side script Ajax call pass to ajax_get_startdate.php script where based on course id got the start date using select query of mysql
public function ajax_get_startdate() {
 $course_id = $_POST['course_id'];
 $result = $this->courses_model->_get_course_options($course_id); //get course start date
 if (!$result) {
  echo 'false';
 } else {
  $datev = $result->start_date;
  $d = explode('-',$datev);
  $day = $d[2];
  $month = $d[1];
  $year = $d[0];
  echo $year.','.$month.','.$day; 
 }
}

No comments:

Post a Comment