in Education by
I'm having this little problem with internet explorer and ajax. So first I used just php, and everything, worked, but because I don't want to reload the page, I use ajax. So I have a form with a checkbox. When someone clicks on the checkbox, my ajaex is called and the input is changed in the db. In firefox there is no problem, but It doesn't work in internet explorer. Here's a part of my code: function changefield($doss, $display){ $.get("update.php",{dossier: $doss, CSQ_DISPLAY:$display}); alert("test"); } echo ' '; It seems that in explorer, I only get the alert when the checkbox was checked. (Problem because it first reads the db if it must be checked or not, so you can change it later). Does someone know where I went wrong? Thank you very much in advance for the answers. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I would prefer to define it like this, I hate using onclick in my HTML: edit FIXED (registered to change instead of click) edit Wrapped in $(document).ready() edit Added a click event as well <?php echo '<input class="ajax_check" id="check_'.htmlspecialchars($r['BC_DOSSIER']).'" type="checkbox" name="CSQ_DISPLAY" '.$checked .' />'; ?> $(document).ready(function() { $('input.ajax_check').click(function() { this.blur(); }); $('input.ajax_check').change(function() { var dossierId = this.id.slice(6); var isChecked = (this.checked) ? 1 : 0; // better to explicitly convert bool to int for HTTP requests $.get('update.php',{ dossier: dossierId, CSQ_DISPLAY: isChecked }); alert('test'); }); }); This will register that handler to all inputs with the className 'ajax_check', without leaving a function cluttering up the window object, and without messing up your HTML. Try it out and see if it fixes the problem - it may not as it does basically the same thing, but it's a better way of doing it IMHO. If you still have a problem, come back to me and we'll debug it. Note that using this approach, it is important that the is executed after the DOM is ready, so it should either be defined in the body after the checkbox or (better) wrapped inside $(window).load() or (best) $(document).ready().

Related questions

0 votes
    Looking for guidance on how to use Angular Elements that will work across other browsers especially with Internet ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I am trying to simulate the look and feel of a Firefox disabled text input: textarea and input text. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I am trying to simulate the look and feel of a Firefox disabled text input: textarea and input text. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    I am in a project where I need to connect to a client's server and retrieve data for some graphs ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    5. Which of the following is not web browser ? * (a) Google Chrome O (b) Mozilla Firefox O (c) Internet Explorer O (d) Notepad Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    internet explorer has been replaced by _________web browser in window 10 Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    Where is the error icon shown in the Internet Explorer? (a) Taskbar (b) Status bar (c) Both ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 21, 2021 in Education by JackTerrance
0 votes
    I have following code and I want to get data from service. I have set everything from what I get ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I have following code and I want to get data from service. I have set everything from what I get ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    I found this example on the official site of DialogFlow using Node.js and it is working fine, but ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    My question is a variant of the question here However, there are two differences: I don't know how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    My question is a variant of the question here However, there are two differences: I don't know how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    How to pass json format data on ajax call?...
asked Dec 10, 2020 in Technology by JackTerrance
0 votes
    Few channels in Slack are listed with a lock symbol in the Explorer because these channels are ___________. A. Private B. Personal C. Public D. Exclusive...
asked Dec 23, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
...