Tag Archives: javascript

how to link Javascript function with wordpress' customize control

Questions: I have added a new section in customize section function select_theme_stylesheet( $wp_customize ){ $wp_customize->add_section( ‘theme_stylesheet_selector’, array( ‘title’ => ‘Select Color’, ‘priorty’ => 50 )); $wp_customize->add_setting( ‘theme_stylesheet_settings’, array( ‘default’ => ‘green’, ‘transport’ => ‘postMessage’ )); $wp_customize->add_control( new WP_Customize_Control( $wp_customize,’theme_stylesheet_control’,array( ‘type’ => ‘radio’, ‘label’ => ‘Theme Scheme’, ‘section’ => ‘theme_stylesheet_selector’, ‘settings’ => ‘theme_stylesheet_settings’, ‘choices’ => array(… Read More »

Reading Json file in php (or javascript) with sub array

Questions: This is my json file maps.json [{ “type”: “FeatureCollection”, “name”: “maps”, “crs”: { “type”: “name”, “properties”: { “name”: “urn:ogc:def:crs:OGC:1.3:CRS84” } }, “features”: [ { “type”: “Feature”, “properties”: { “IDLo”: “1”, “SoHieu”: “1-1”, “KyHieu”: “C”, “TenLo”: “C1-1”, “TenCty”: “CMC Data Center”}, “geometry”: { “type”: “Polygon”, “coordinates”: [ [ [ 106.791800519464871, 10.854928689692501 ], [ 106.792069337729856, 10.855930098557222… Read More »

JavaScript not firing in header or footer

Questions: I’m running a simple on scroll event to see if my JavaScript is firing, but it doesn’t do anything whether it’s in the header of footer? header.php <header id=”masthead” class=”site-header” role=”banner”> <script type=”text/javascript” src=”assets/src/js/load-more.js”></script> </header><!– #masthead –> footer.php <script type=”text/javascript” src=”assets/src/js/load-more.js”></script> load-more.js $(window).scroll(function() { if($(window).scrollTop() + $(window).height() > $(document).height() – 100) { alert(“near bottom!”);… Read More »

Save file object into a file – sweetalert2 – javascript – php

Questions: I set up a SweetAlert2 popup with a file input (only images are allowed), according to example: const {value: file} = await swal({ title: “Image upload”, text: “Upload your profile image”, input: ‘file’, inputAttributes: { ‘accept’: ‘image/*’, ‘aria-label’: “Upload here your image” } }); and then I sent an ajax request through XMLHTTPRequest to… Read More »

Fetch error while post sale: SyntaxError: Unexpected end of JSON input (javascript) [on hold]

Questions: I got this error when I try the send an object to process with php. I do not know if it’s a problem with the headers or it’s a problem with the php configuration. Please, an idea. process() { console.log(‘Procesar’); const sale = { items: this.items, total: this.total, numItems: this.numItems, }; console.log(JSON.stringify(sale)); fetch(‘action.php’, {… Read More »

Create a JSP element with JavaScript

Questions: I need to create a jsp form with javascript. The problem is to assign the data path. Imagine $form.work = “Hello Work”; If I create the form with html: <div id=’workForm’> Work:<input value=${form.work}></input> </div> The input will show the work value (Hello Work). But I need to create this div form with js, something… Read More »

FaceBook API JavaScript SDK in FireFox doesn't connect

Questions: I’m using FireFox to make the proves with the FB API for JavaScript, in Chrome and Opera, and also in FireFox for Developers it works, but in the normal FireFox it doesn’t works and appear this message in the console (i put a console.logwhen enter in the FB.API. to be mor specifically FB.api(‘/me?fields=id,name,email,picture’,function(response){ console.log(“response”,… Read More »