ajax

Node.js - csurf invalid csrf token

冷暖自知 提交于 2021-01-29 18:57:47
问题 I'm using the npm module csurf for generating a token. First I get the token from the server, which I then use for the /register request. When I'm reproducing the same steps with postman, it seems to work, but unfortunately not in the application. There it always throws the error message that the token is invalid --- Server side --- csrfProtection.js import csrf from 'csurf'; export default csrf({ cookie: true }); router.js import csrfProtection from './../../config/csrfProtection' router.get

Populate select field after user input (Advanced Custom Fields)

≯℡__Kan透↙ 提交于 2021-01-29 18:29:12
问题 I have an option page with some fields. A repeater field that has 2 sub fields: DATE (datepicker field) and SESSION (select field with options: 1 and 2) And also 2 textarea fields that will be used to populate the TIME field in a frontend form. TIMES SESSION 1: 12:00 12:30 13:00 13:30 14:00 14:30 15:00 TIMES SESSION 2: 17:30 18:00 18:30 19:00 19:30 20:00 20:30 I have a frontend form with a DATE (datepicker) and a TIME (select) field. When a user selects a DATE in frontend that matches a DATE

vanilla js vs jQuery ajax call

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 18:22:01
问题 I want to do an ajax call with vanilla js. In jQuery , I have this working ajax call: $.ajax({ url:"/faq/ajax", datatype: 'json', type:"POST", data: {search:'banana'}, success:function(r) { console.log(r['name']) } }); Vanilla JS: var search = document.getElementById('searchbarfaq').value; var r = new XMLHttpRequest(); r.open("POST", "/faq/ajax", true); r.onreadystatechange = function () { if (r.readyState != 4 || r.status != 200) return; console.log("Success: " + JSON.parse(r.responseText));

Pass JS variable to PHP using ajax

旧巷老猫 提交于 2021-01-29 18:04:32
问题 I know this has been asked on here but none of the answers I found answered my question. I have a PHP/HTML file that the users view. When they click on a button, it creates a JS variable which I would like translated into a PHP variable. Using that variable, I would like to update the contents of a div box by calling a PHP function which populates the box with info from the server. My questions: Can this be done with only 1 php file? Do I have to have the user reload the page after I refresh

Custom JSON error response fails when no error

♀尐吖头ヾ 提交于 2021-01-29 18:00:28
问题 This is a new area for me. I've created custom JSON error outputs to alert users if they enter a name and/or an email which already exists. I'm trying to spit out the errors and then if no error exists, continue. Unfortunately I'm getting the following message in Firefox console: "Uncaught SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data." It's weird as I have 3 JSON error variations set up which are working (1 name, 2 email,3

JQUERY/ AJAX Request not going through and conflicts

时光总嘲笑我的痴心妄想 提交于 2021-01-29 17:53:37
问题 I have included a contact form in my page. In the same page I have a script that gets prices depending on the value of a dropdown. Now when I try to submit the contact message I have a conflict with the script for prices. Basically it tries to run it and I have no clue why. Also the contact form when submitted never works...I just get a new page to open with URL..?message=blablabla Any idea what is going wrong? I am working on Laravel 4.2 and so the route you see redirects to my php function.

Conditional dropdown is needed if the option is no then only the other should appear if not it must be null [closed]

痴心易碎 提交于 2021-01-29 17:42:55
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 months ago . Improve this question <div class="form-group"> <label asp-for="son" class="control-label"></label> @*<input asp-for="son" class="form-control" />*@ <select name="son" id="son"> <option value="none" selected="selected"> -- choose one --</option> <option>Yes</option> <option>No</option> </select>

Scrap peekyou.com ( having POST METHOD)

强颜欢笑 提交于 2021-01-29 17:31:25
问题 Please see the output which I am getting I am trying to scrap peekyou.com which is kind of peoples search engine. They use POST method of php.I am using requests.post method of requests library to scrap the results . suppose a persons name is "john coasta" then the target url would be : peekyou.com/john_coasta import requests import json payload = { 'formdata' : {'md5': '4a9050a569e0f7d862b771926f7abc57', 'asynchronous': 'true'} } req = requests.post('https://www.peekyou.com/shantanu_sharma',

reload a PHP condition with ajax (Woocommerce)

泄露秘密 提交于 2021-01-29 17:27:10
问题 I have added one custom field (select tag) to checkout page that is output of two conditions: 1st >> If "Victoria" state is selected then display first condition as custom field. 2nd >> If any other state is selected then display second condition as custom field. // Add custom checkout datepicker field to checkout page add_action( 'woocommerce_before_order_notes', 'checkout_display_datepicker_custom_field' ); function checkout_display_datepicker_custom_field( $checkout ) { echo '<div id=

Change img properties (src, alt…) based on AJAX success (and fix my ajax ;) )

江枫思渺然 提交于 2021-01-29 16:36:45
问题 The image link I'm using: echo "<br/><div class='right' id='post" . $id . "'> <img id='thumb' src='/images/like.png' title='Like it?' alt='Like button' onClick='likeButton(" . $id . ");'>( " . getLikes($id) . " )</div><br/>"; and the JavaScript is: function likeButton(id) { $.ajax({ url: "../../likes/" + id, type: "post", data: { id: id}, success: function(likes) { $('#post' + id).html(likes); }}); } "likes" is the PHP function that adds the click to the db, and it also returns the number (