javascript - Retrieving JSON from PHP File, and Append inside div -


Is trying to pass the real-time graph update within my site i basically a php in every 30 seconds Trying to reload the file, to deselect it, I've dynamically unpacked the data of PHP as json code as shown below. The ad also contains and , which retrieves the database to retrieve the file. {"YesterdayCalculateCR": "35%"} {"todayCalculateCR": "5%"} {"todayEPC": "0.20"} {"todayCTR": "34%"} {"yesterdayCalculateCR"} { {"MonthEPC": "0.03"} {"yesterdayCTR": "24%"} {"monthCalculateCR": "14%"} {"monthEPC": "0.07"} {"month CTR": "24%"}

Actually now I want to put some jquery code on my index.php page to load this file, explain json code and add data to the correct divs.

Example: & lt; div class = "yesterdayEPC" & gt; 0.03 & lt; / Div & gt;

I am looking at jquery.com and basically taking the above mentioned Jason data, and on the stack overflow for ways to add it.

$ ("Dashboard-stats.php", function (data) {$ ("body") .append ("Kleppy:" + data. If EPC) // John.Append ("Time:" + Data yesterday EPC); / / 2pm}, "json");

This is a bit about creating a PHP file:

$ month_visits = mysql_num_rows (Mysql_query ("SELECT * FROM locker_portport WHERE uid = '$ user_id' and month = '$ month_date' ")); $ Month_clicks = mysql_num_rows ("Select FROM report WHERE uid = '$ user_id' and month = '$ month_date' and Status = '1' ")); $ Month_leads = mysql_num_rows ("Select FROM report WHERE uid = '$ user_id' and month = '$ month_date' and Status = '2' ")); If ($ month_head == "" $ month_click == "") {echo json_encode (array ("month calculateCR" => n / a ")); Echo json_encode (array ("monthpc" = & gt; "n / a")); } And {$ monthCalculateCR = number_format ($ month_clicks / $ month_leads) "%"; Echo json_encode (array ("monthcimalcr" => gt; $ monthCalculateCR. "" "))); $ Month EPC = number-format ($ month_heads / $ month_clicks, 2). ""; Echo json_encode (Array ("month CRC" = "" Month "); $ month EPC." "" ");} If ($ month visits ==" ") {echo (" month CRR "= > "N / A");} and {$ month CTR = number-format ($ month_click / $ month_ visit, 2) * 100 "%"; echo json_encode (array ("month CRR" => "Code" setTimeout To call the function $ .get () the jQuery method to remember the PHP method that eats JSON.

  reload ( ); Repeat the function $ ('$ MyDiv'); $ (.get) {$ .get ("yourFile.php", function (data) {// updated data data by json.data = $ .parseJSON} .append );}); SetTimeout (reload, 30000);}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -