javascript - Pick Date from Jquery Calender and Check it WIth DB and Print Events on That Date -
I have a jquery calendar that stores in the selected "date" variable ... I get the events stored on it Want to print that date from the database and print them ... Please help me ...
& lt; Div id = "calendar" & gt; & Lt; / Div & gt;
Date:
& lt; Script & gt; Var x = ''; $ ('# Calendar'). DatyPirate: "yyyy / mm / dd", day names: ['sun', '', ' Select 'Work' (date text) '$' ('# event-date'). (DateText) x = 'Date' DateText; // Alert (x); $ .ajax ({type: "post", url: 'check_events.fpp', data: {dateText: x}, datatype: 'jason', success: function (data) {warning ("Data");}}}}}}); & Lt; / Script & gt;
check_events.php: -
& lt; Php mysql_connect ("localhost", "root", "") or die (mysql_error ()); Mysql_select_db ("user") or die (mysql_error ()); If (isset ($ _ POST ['datetext'])) {$ x = date_format ($ _ POST ['datetext'], 'YYY-MM-DD'); // $ uname = mysql_real_escape_string ($ x); $ Sql_check = mysql_query ("Select * from events where date = '$ x'"); While ($ res = mysql_fetch_assoc ($ sql_check)) {// print_r ($ res); Echo json_encode ($ res); }}? & Gt;
How to print $ res json variable in an AJAX call ...
It should be alerts
without quotation marks. You actually send "code" back to Ajax calls instead of "code". Also it is a good practice to implement Ajax error:
event so that you can troubleshoot issues. Example below:
$ .ajax ({// your other stuff here error: function (Excerpt, Status, P3, P4) {var err = "Error" + "" + Status + "" + P3 + "" + p4; if (xhr.responsetext & xhr.responseText [0] == "{") console.log (mistake);}}); });
Comments
Post a Comment