php - Ajax not returning any atributes -
php - Ajax not returning any <table> atributes -
this rather weird, , rather complicated, im going seek explain best can. im making calendar hand, plan on open sourcing etc. im going , sense of google calendar, seem best, plan on 1 upping + open source. running flawlessly except when click previous month, in order view previous month, ajax query ran, php returns new calendar, when renders renders without any <table>
elements other havent nail snag yet ideas? heres code/images:
html:
//function utilize xml function xml(){ //need set xml run php query if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("calendar").innerhtml= xmlhttp.responsetext; } }; } //function select previous month function previousmonth(str){ //since previous month need take month -1 var month = str - 1; //if 1.. needs 12! if(str == 1) { month = 12; } //call xml xml() //send dat query xmlhttp.open("get","redraw.php?month="+encodeuricomponent(month),true); xmlhttp.send(); }
redraw.php:
// draws calendar function draw_calendar($month,$year){ // table headings $headings = array('sunday','monday','tuesday','wednesday','thursday','friday','saturday'); $calendar= '<tr class="calendar-row"><td class="calendar-day-head" id = "cell" style = "min-width:150px;">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; // days , weeks vars $days_last_month = date('t',mktime(0,0,0,$month-1,1,$year)); $running_day = date('w',mktime(0,0,0,$month,1,$year)); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); $today = date("d"); // row week 1 $calendar.= '<tr class="calendar-row">'; // print "blank" days until first of current week for($x = 0; $x < $running_day; $x++) { $calendar.= '<td class = "calendar-day-prev" id = "cell" style = "min-width:150px;"><div class = "day-prev- number" style = "color:#929d9d">'.(($days_last_month -($running_day - 1)) + $x).'</div>'; $calendar.= str_repeat('<p> </p>',2); $calendar.= '</td>'; $days_in_this_week++; } // maintain going days.... for($list_day = 1; $list_day <= $days_in_month; $list_day++) { $calendar.= '<td class = "calendar-day" id = "cell" style = " min-width:150px;"'; //if day today need have differnet style it... if($list_day == $today) { $calendar.= ' style = "background-color:#9494b8;font-weight:bol;">'; } else { $calendar.= '>'; } // add together in day number $calendar.= '<div class = "day-number">'.$list_day.'</div>'; // need query entries per day $calendar.= str_repeat('<p> </p>',2); $calendar.= '</td>'; if($running_day == 6) { $calendar.= '</tr>'; if(($day_counter+1) != $days_in_month) { $calendar.= '<tr class="calendar-row">'; } $running_day = -1; $days_in_this_week = 0; } $days_in_this_week++; $running_day++; $day_counter++; } // finish rest of days in week if($days_in_this_week < 8 && $days_in_this_week != 1) { for($x = 1; $x <= (8 - $days_in_this_week); $x++) { $calendar.= '<td class = "calendar-day-after" id = "cell" style = " min-width:150px;"><div class = "day-post-number" style = "color:#929d9d;">'.$x.'</div>'; $calendar.= str_repeat('<p> </p>',2); $calendar.= '</td>'; } }; // final row $calendar.= '</tr>'; // done, homecoming result homecoming $calendar; } //draw calendar $year = date ('y'); $month_title = date ('f'); //sent variables if(!empty($_request['month'])) { $month_display = $_request['month']; } else { $month_display = date ('n'); } echo draw_calendar($month_display,$year);
heres depiction of whats going on:
what should like:
on first click:
what inserted js <div id = "calendar">
what returned php(this part seemingly correct):
document.getelementbyid("calendar").innerhtml= xmlhttp.responsetext;
you inserting table rows div
, not table
. add together missing table tag or append info table.
nitpicks - have "header cells" not utilize th elements. not using thead , tbody.
php javascript ajax
Comments
Post a Comment