function being called twice |
This is a strange issue. I have a chrome extension (written in javascript and running in the browser) that send XMLHttpRequest over to my CI program. There is a controller on my server called Subit_backend and it has a function called logger_survey (/Subit_backend/logger_survey). This works fine, the logger_survey() runs on the server and it sends back a message to the calling javascript. Works fine. Then immediately logger_survey() is firing again. I have a debugger set at the first line of logger_survey so I can see it is being called again.
I am pretty sure that my javascript code is not running the send twice. (I also have a debugger on this). Code: var xhr = new XMLHttpRequest();
proof that an old dog can learn new tricks
Well, I ran a packet sniffer while testing. It seems that the browser IS sending the request twice. I have no idea of why this is and I am fairly certain that it is not running my xhr.send(json) code twice. Here is the packets from the sniffer.
BTW, I do get two 200 responses. How can I tell where in my javascript code (which is in a browser extension) the 2nd send is being initiated?
proof that an old dog can learn new tricks
Show your event handler. Is it just a click event?
(12-15-2018, 10:00 AM)skunkbad Wrote: Show your event handler. Is it just a click event?Hey Brian. Code: $('#btnSubmitSurvey').button().click(function () { Code: //this stops the dblclick error Code: if (request.task =="log_results_survey"){
proof that an old dog can learn new tricks
Is '#btnSubmitSurvey' a <input type='submit' ...> element? If so you probably need to use event.preventDefault()
Code: $('#btnSubmitSurvey').button().click(function (event) {
(12-15-2018, 11:48 AM)richb201 Wrote:(12-15-2018, 11:42 AM)dave friend Wrote: Is '#btnSubmitSurvey' a <input type='submit' ...> element? If so you probably need to use event.preventDefault() Yes, that answers my question. It is not a type="submit"
I have not been able to find the answer although it does sound a lot like a bug in Chrome that has been around for a few years. https://productforums.google.com/forum/#...-gfRJLCCjg
Either way, What I'd like to do is to see if I got the same is_ajax_request() within 1 second, just flush the second one. How can I do this easily?
proof that an old dog can learn new tricks
I appended getTime() value on the the end of the data being sent from the browser. From Wireshark:
from the first POST value: 1545054382811 from the second POST value: 1545054382812 Notice that they are just one msec apart. Can I assume that the function send_to_logger_survey(request, sender, sendResponse) is running twice? Here it is again. I doubt that in that one msec an answer came back from the remote server and I replied again. It almost seems like a javascript "bounce". Any ideas on how to diagnose this problem?
proof that an old dog can learn new tricks
Is there any support for insert ignore? I have this
$this->db->insert('survey_tasks', $data); and I would like to skip inserting if it already exists.
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |