![]() |
How to implement EventSource on Codeignigter app? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: How to implement EventSource on Codeignigter app? (/showthread.php?tid=75572) |
RE: How to implement EventSource on Codeignigter app? - SmokeyCharizard - 02-25-2020 (02-24-2020, 10:05 PM)dave friend Wrote: Send me a PM telling me where your repo is and I'll take a peek.So I sent you the repo, but I can't tell if you got it. I did find that I am also sending cURL requests along with the SOAP requests. I think this is what might be conflicting with everything, as I can send SSE's from the model until I make my first cURL request. EDIT: scratch that, the data values were just not being passed via fetch. This is going to work! Thanks! RE: How to implement EventSource on Codeignigter app? - dave friend - 02-25-2020 You sent it how? I have not received anything except the link to a GitHub page which did not work. But it sounds like you're making progress. Good. RE: How to implement EventSource on Codeignigter app? - SmokeyCharizard - 02-25-2020 (02-25-2020, 10:23 AM)dave friend Wrote: You sent it how?I sent it as a private message, but I suppose it doesn't matter any more! Now I just need to figure out how to send the form data to the controller via fetch. I am calling the controller, but the data isn't getting passed... You've been a MAJOR help, though! RE: How to implement EventSource on Codeignigter app? - dave friend - 02-25-2020 (02-25-2020, 10:38 AM)SmokeyCharizard Wrote: I sent it as a private message, but I suppose it doesn't matter any more! Now I just need to figure out how to send the form data to the controller via fetch. Try something like this to post the form data. Code: const form = new FormData(document.getElementById('login-form')); RE: How to implement EventSource on Codeignigter app? - SmokeyCharizard - 02-25-2020 (02-25-2020, 11:51 AM)dave friend Wrote:I managed to display this...(02-25-2020, 10:38 AM)SmokeyCharizard Wrote: I sent it as a private message, but I suppose it doesn't matter any more! Now I just need to figure out how to send the form data to the controller via fetch. "------WebKitFormBoundaryBkqBFPIomAOOTUPR Content-Disposition:_form-data;_name"]=> string(187) ""date" 2019-10-03 09:44:30 ------WebKitFormBoundaryBkqBFPIomAOOTUPR Content-Disposition: form-data; name="dateTo" 2019-10-03 09:46:30 ------WebKitFormBoundaryBkqBFPIomAOOTUPR-- " [0]=> string(187) ""date" 2019-10-03 09:44:30 ------WebKitFormBoundaryBkqBFPIomAOOTUPR Content-Disposition: form-data; name="dateTo" 2019-10-03 09:46:30 ------WebKitFormBoundaryBkqBFPIomAOOTUPR-- " How to I parse this to just the the date, dateTo, and sandbox? I tried json_encode() to no avail. My fetch code: const url = <?= "'".base_url('classic/classicFirearmByDate', 'http')."'"; ?>; var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/x-www-form-urlencoded"); const form = new FormData(document.querySelector('#form1')); // The parameters we are gonna pass to the fetch function let fetchData = { method: 'POST', headers: myHeaders, body: form, } RE: How to implement EventSource on Codeignigter app? - dave friend - 02-25-2020 I'm not very confident I understand the question. If you're asking how you get the form inputs at the controller - that is not changed from your original post. PHP Code: $date = trim(htmlspecialchars($this->input->post('date'))); RE: How to implement EventSource on Codeignigter app? - SmokeyCharizard - 02-25-2020 (02-25-2020, 02:54 PM)dave friend Wrote: I'm not very confident I understand the question. If you're asking how you get the form inputs at the controller - that is not changed from your original post.Thanks for the reply! I should have been more specific in my response, Yes, it seems like fetch will only send the form data in a format like above, with the weird "WebKitFormBoundary" stuff. I tried your trim solution, but it returned an empty string. EDIT: I figure it out. The header was causing problems lol! RE: How to implement EventSource on Codeignigter app? - dave friend - 02-25-2020 (02-25-2020, 03:16 PM)SmokeyCharizard Wrote: Thanks for the reply! I should have been more specific in my response, Let me try again. At the controller function classicFirearmByDate() you can capture the form input fields by using PHP Code: $date = $this->input->post('date'); Don't worry or mess with the "WebKitFormBoundary" stuff. The server will parse that and put the <input> data into $_POST just like when you use a normal <form> submit. The trim and htmlspecialchars calls were code you had in your original post, so I left them in place. RE: How to implement EventSource on Codeignigter app? - SmokeyCharizard - 02-25-2020 (02-25-2020, 03:30 PM)dave friend Wrote:I figured it out. If you remove the header setting I have, then it submits! Unfortunatly, I can seem to send any messages in my model if the echo is inside of the main process loop. I'll pm you my github so you can see.(02-25-2020, 03:16 PM)SmokeyCharizard Wrote: Thanks for the reply! I should have been more specific in my response, (02-25-2020, 03:30 PM)dave friend Wrote:Encase you can't see my message again, here's the pastebin. https://pastebin.com/eupHEA0c(02-25-2020, 03:16 PM)SmokeyCharizard Wrote: Thanks for the reply! I should have been more specific in my response, RE: How to implement EventSource on Codeignigter app? - dave friend - 02-25-2020 (02-25-2020, 03:58 PM)SmokeyCharizard Wrote: Encase you can't see my message again, here's the pastebin. https://pastebin.com/eupHEA0c I can see your PM. I cannot send a reply to you. Go the the edit options of your profile and check the box next to Receive private messages from other users. |