0

Possible Duplicate:
Need to solve IE 8 Jquery problem

Hi,

My client's PHP server doesn't support as it has PHP Version 5.1.6. In my project, I am getting date values from the server side and disable the dates in jquery datepicker.

Below is my code:

$(document).ready(function () {

                                $('#textfield1').attr("disabled", true);
                                $('#textfield2').attr("disabled", true);
                                $('#textfield1').datepicker( "destroy" );
                                $('#textfield2').datepicker( "destroy" );
                                $("#loading2").html('<img src="images/loading.gif"/>');
                                var dataString = 'v=OV';
                                $.ajax({
                                    type: "GET",
                                    url: "include/getdate.php", 
                                    cache: false,
                                    data: dataString,
                                    dataType: "json",

                                    success: function(data){

                                        $(".tempimg").hide();
                                        $('#textfield1hid').removeAttr("disabled");
                                        $('#textfield2hid').removeAttr("disabled");
                                        $('#textfield1hid').removeAttr("style");
                                        $('#textfield2hid').removeAttr("style");
                                        $("#textfield1hid").datepicker({ 
                                            showOn: "button",
                                            buttonImage: "/images/calendar.gif",
                                            buttonImageOnly: true,
                                            dateFormat: 'd M yy',
                                            altField: "#textfield1",
                                            altFormat: "yy-mm-dd",
                                            beforeShowDay: reservedDates
                                        });
                                        $("#textfield2hid").datepicker({ 
                                            showOn: "button",
                                            buttonImage: "/images/calendar.gif",
                                            buttonImageOnly: true,
                                            dateFormat: 'd M yy',
                                            altField: "#textfield2",
                                            altFormat: "yy-mm-dd",
                                            beforeShowDay: reservedDates
                                        });
                                        natDays = data;
                                        function reservedDates(date) {
                                            for (i = 0; i < natDays.length; i++) {
                                              if (date.getMonth() == natDays[i][0] - 1
                                                  && date.getDate() == natDays[i][1]) {
                                                return [false, natDays[i][2] + '_day'];
                                              }
                                            }
                                          return [true, ''];
                                        }
                                            $("#loading2").html('');
                                        },
                                    error: errorCallback
                                    });
                                    return false;
                                });


                            function errorCallback(jqXHR, textStatus, errorThrown) {
                                alert(jqXHR);
                                alert(textStatus);
                                alert(errorThrown);
                            }

I am getting a customized array response from the server: This is a sample response from the server:

[[04,01],[04,01],[04,02],[04,02],[04,03],[04,03],[04,13],[04,13],[04,14],[04,14],[04,15],[04,15],[04,16],[04,16]]

This code works perfectly fine in Firefox and IE7, but when rest of the browser including IE8 and Chrome is not working as I expected ie. not showing the datepicker with dates disabled. Throws and parseerror and Syntax Error. If I remove the dataType:"json" from the ajax code, none of the browser giving me the proper answer but datepickers are showing without disabling the dates. Someone help me to fix this problem

Thanks

Community
  • 1
  • 1
Mujahid
  • 1,227
  • 5
  • 32
  • 62

0 Answers0