ajetrumpet Posted December 11, 2019 Share Posted December 11, 2019 (edited) does anyone have an example of new code that is used this day in age for combining js and PHP to produce dynamic content on a webpage? I have looked at this from w3schools: https://www.w3schools.com/php/php_ajax_database.asp but I believe that XMLHttpRequest is really old. If I rememeber my reading right, it was replaced by fetch() a long time ago. I think i understand everything that is on that tutorial page, but I would love to see a video tutorial on this subject. can anyone here point me to such a resource? Edited December 11, 2019 by ajetrumpet Quote Link to comment https://forums.phpfreaks.com/topic/309667-asynch-websites-with-php-and-js/ Share on other sites More sharing options...
NotSunfighter Posted December 11, 2019 Share Posted December 11, 2019 For information on fetch() see https://developers.google.com/web/updates/2015/03/introduction-to-fetch, and https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch. Another source is https://css-tricks.com/using-fetch/. Youtube videos abound, See Quote Link to comment https://forums.phpfreaks.com/topic/309667-asynch-websites-with-php-and-js/#findComment-1572431 Share on other sites More sharing options...
ajetrumpet Posted December 12, 2019 Author Share Posted December 12, 2019 (edited) thank you sunfighter. I will check those out. moreover, I have watched a few episodes at the following channel as they cover some topics that I have not yet been exposed to: Edited December 12, 2019 by ajetrumpet Quote Link to comment https://forums.phpfreaks.com/topic/309667-asynch-websites-with-php-and-js/#findComment-1572447 Share on other sites More sharing options...
JacobSeated Posted December 12, 2019 Share Posted December 12, 2019 XMLHttpRequest may be old, but it is not going away anytime soon. The main problem I had was the asynchronous "callback" hell of JavaScript, especially coming from a PHP background. You can not easily return the result of a HTTP request to the calling script. Instead, you have to use a callback function to deal with the response data. Afaik, fetch makes this easier, since it can wait for a "promise" to be fulfilled (a server responding). I Have not really used it much, but now that I got XMLHttpRequest working with callbacks, I am not planning on changing it. Probably should look into it. Quote Link to comment https://forums.phpfreaks.com/topic/309667-asynch-websites-with-php-and-js/#findComment-1572461 Share on other sites More sharing options...
ajetrumpet Posted December 13, 2019 Author Share Posted December 13, 2019 I will get back to you guys about what i've implemented once I figure out what I'm doing and have read through enough content to be confident. thanks much everybody! Quote Link to comment https://forums.phpfreaks.com/topic/309667-asynch-websites-with-php-and-js/#findComment-1572488 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.