finally a tut on AJAX+mysql+vanilla JS. everyone is teaching this using jQuery, but i don't need to use the entire library just for it's AJAX methods. i'm trying to build a live chat app and am going to try it using the info here. THANK YOU.
You're welcome. Good luck with your live chat app. I have already created a tutorial for live chat app, below is the link: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Ozrm_xftcjQ.html
Absolutely brilliant, been looking for an ajax tutorial that handles arrays and finally someone goes a step beyond the normal simple data examples. New subscriber bro.
👍 This was good! But for a noob to PHP, audio explanations would have made this perfect. Even though a book is silent, one can still read code explanations and details.
Hello there, can you help me? I want to use that "data" array in an if to check is a certain column is set to 0 or to 1, i defined var data = {} outside of the function but It's not working, I'm doing an if (data["article_flag(the column)"] == 1) { function to execute }
This is a new language for me, as I have been writing in pure PHP for years. I was able to follow this video and retrieve all rows from my db where a column had a specific value. The problem is, that when I add a new row in the db that has the same value at from my WHERE clause, the new row never shows up. I still have to force a refresh (F5). This is the same scenerio in multiple web browsers, so I'm thinking it is in the code (probably my fault, I am sure!) Any thoughts on why this would not show the new rows? The table I am querying will be INSERT only, no UPDATE or DELETE, to maintain data integrity. I just edited one of the rows directly from the database (not yet live, it is in the testing phase) to see if the changes would show on existing rows that are being displayed on my test page, and they don't show updates either! What am I missing?!?
You need to insert the record using AJAX. You can follow this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-UDmAlpYVwbU.html When the response is received from this AJAX, you can send ajax the AJAX to get all records.
I added a Button. So that the result is displayed only after pressing the button. But the problem is that the result are displayed multiple times on button press. How to clear this?
Hi. Because if you have a lot of data then it would be difficult to send as PHP objects. So we send them as JSON string. Now data will be sent as string not objects.
Thanks for this!! Beeen searching for pure js live data.. anyway, is it possible for me to put a button at the end of the table? hope you could recommend me a video that includes an action at the end of the table where the user could delete or edit the column.. thank you!
Searching for days, and found this. Absolutely amazing. Best is so many other sites don't have code download, thanks for that. The mysqlsampledatabase.sql to create the database couldn't be better. Thank you so much for this, from a beginner who has learnt so much from you.
@@AdnanAfzal565 Thank you. I know only php mysql. If I add this feature, in average how much time it saves for a general page with perhaps 20 fields to be printed?
Simple code will work fine. But if you have a very complex sql query, are performing certain operations on arrays and objects. Or using 3rd party library, then it is a possibility.
Hello, Thanks a lot for this... Doing just that i seem to be limited to retrieving only 150 rows... if i try to retrieve more, i get an empty string instead... I'm on Xampp/mariaDB - I tried to set the post_max_size to 0 in the php.ini file, to no avail... even restarted the server afterwards... still limited... any thoughts?
@@AdnanAfzal565 Thanks for getting back to me so quickly - turns out it was accents.. the 151st row had an accent and because of that the query returned an empty set... been trying to fix this but none of the solutions i found online are helping so far :/
@@AdnanAfzal565 thanks, still doesn't work unfortunately :/ Getting this: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data Also converted my DB, Table and column to utf8mb4 - to try and fix this... doesn't seem to work at all
It will send the request to server every second. You can use Node JS to get realtime data. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sMPayYZFodE.html
I figured out that the problem is In array_push statement. Array_push($data, $row); I tried to delete the $row var in array_push statement and the result is not duplicated. Inshort the problem is finally solved. But still I don't know the conflict after I removed this. But I still wonder why my data is duplicated output, while in your case is not? I didn't understand yet what is the main purpose of array_push.
@@markystudio14 array_push insert the data in array. Check if you are receiving duplicate data from database. May be the problem is not in PHP code, but in MySQL query.
Can you please make a video for fetching only when there is new data using long polling method, because as I have heard, this method would put a strain on the server.
Hmmm..... That could be achieved in pure PHP in a couple of lines.... I suppose if you have an adfested page where you want to only update the 3 square inches of actual information of value without loading all the ads again, JavaScript is useful. Still.. at least a video showing Ajax WITHOUT using JQuery. Good.
@@AdnanAfzal565 I have to use timer or something like this to refresh data on website ? When I am changing data in database now, website displays the same data like before (are unchanged). When I refresh website only by F5 - data is changing. What's wrong with me ?