Skip to main content

Posts

How to fix Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (

I need some help with this error: Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at Object.success However, on my webiste on every page I have the some contact form where on every page data need be sent to different email address, so all email addresses I save and get from database. Without jQuery code form is sent successfully, all data inserted into db, and in place of jQuery AJAX response I get valid JSON like: [{"response":"success","content":"Thanks John Doe! Your message is successfully sent to owner of property Hotel Paris! You will get an answer soon!"}] or if I try to use JSON_FORCE_OBJECT in this case I get valid JSON too, with content {"0":{"response":"success","content":"Thanks John Doe! Your message is successfully sent to owner of property Hotel Paris! You will get an answer soon!"}} but with jQuery and AJAX instead a displey a user success...

function on Contact Form 7 submission not working

I'm using Contact Form 7 in Wordpress, What I want to do is to call a specific JavaScript function when the form I created is submited show popup successful. and this my code add_action('wpcf7_mail_sent', function ($cf7) { // Run code after the email has been sent $wpcf = WPCF7_ContactForm::get_current(); $wpccfid=$wpcf->id; // if you wanna check the ID of the Form $wpcf->id if ( '3854' == $wpccfid ) { // Change 123 to the ID of the form echo ' <div class="modal" id="myModal2" role="dialog" style="display:block;" tabindex="-1"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content no_pad text-center"> <button type="button" class="close" data-dismiss="modal">&times;</button> <div class="modal-header heading"> <h3 clas...

Using Content-Security-Policy to allow ws connections on https website

I have a HTTPS website which needs to communicate with a backend securely. I also need it to be able to interface with some hardware that only accepts ws connections (NOT wss). I am wondering whether it is possible (and if so, exactly how) to connect with this hardware. I read here that setting the Content-Security-Policy header to certain values can help enable this. I was wondering if anyone knows whether this approach will work, or if they have suggestions for any other approaches. Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

Show / hide element based on which option was selected [closed]

What would be the JavaScript code to display the input field if I choose the second <option> tag and reverse (do not display input) if I choose the first <option> ? <div id="bmi"> <p id="head"> BMI Calculator </p> <p><b>Select the Measure <select id="method" onchange="standard()"> <option id="metric">Metric</option> <option id="standard">Standard</option> </select> </b></p> <p><b>Input your Height Below:</b></p> <br> <input type="text" id="height" /> <p><b>Input your Weight Below:</b></p> <input type="text" id="weight" /> <br> <button id="onSubmit">Calculate</button> <br> <h1 id="result"></h1> </div> Via Active questio...

how to append created div to parent div?

i am trying to create the new pieces on the board, and then append them to the starting section. I keep getting 'null' displayed when appending the newly created div. const playerOneStart = function(){ createP1Captain= document.createElement('div'); createP1Captain.setAttribute('id', 'p1Captain'); createP1Bomb = document.createElement('div'); createP1Bomb.setAttribute('id', 'p1Bomb'); createP1Flag = document.createElement('div'); createP1Flag.setAttribute('id', 'p1Flag'); createP1Major = document.createElement('div'); for(i=0; i<6; i++){ createP1Major.setAttribute('class', 'p1Major'); }; console.log('creating p1 pieces') }; const appendP1 = function(){ p1Cont.append(p1Major) also this is defined const p1Cont = document.querySelector("#pieceHolder > div.p1Container") and append ch...