How to implement EventSource on Codeignigter app? |
(02-24-2020, 05:39 PM)SmokeyCharizard Wrote: So I just tried your code out, and when I submit the form, a white page loads with the timestamp being loaded periodically. Do you understand that when you submit a form the action URL (i.e. c_controller/classicFirearmByDate) is a redirect? That's why the page turns white. You have sent the browser to another controller. The easiest fix requires more JavaScript. You need to catch the submit event and stop the normal HTML process by preventing the browser from doing the event. Then you use javascript to POST the data using the Fetch API. The argument to Fetch should be the action that you used for the form. By doing all that you don't leave the page where you want to display the messages from EventSource. Remove the $this->load->view(...) lines from C_controller::classicFirearmByDate() As I said very early on in this thread, if you want to go to another page when processing is done, you will have to use javascript. This probably means redirecting from the Promise that Fetch returns. All that said, I have never combined Fetch and EventSource so I don't know what, if any, problems using them at the same time might cause. Happy Experimenting! |
Welcome Guest, Not a member yet? Register Sign In |