2018-10-22         Janet

How to solve 'Access-Control-Allow-Origin' error when trying to access api from localhost

I've seen a lot of topics on this error, but I'm very new to js and apis, so I couldn't really understand much, so I apologize for noob status.I'm trying to access an api from sportradar. I'm testing it out on a simple react project created from create-react-app and using axios. When I console.log the data I get these errors: https://dzwonsemrish7.cloudfront.net/items/372w3g2b3F141t2P0K1G/Image%202018-09-04%20at%2011.33.38%20AM.pngI guess I can't access it from a local host? here is my function with the request:getPlayerInfo() { const apiKey = "my-api-key"; const playerID...

 javascript                     1 answers                     47 view
 2018-10-22         Camille

Pass data from JS to PHP via XmlHttpRequest

I'm confronting now with a problem, which consists in sending a JS object to PHP, and I found that it should be done via HtmlHttpRequest, but the problem is that I'm a novice in PHP,and furthermore, I do not understand very well how this XmlHttpRequest works. I've tried different methods but, the one which I found suitable for me, returns constantly the same error. The code will be posted below, and now about the problem, I canperform this request, but when I perform this, the PHP side returns me an error message that there exists an undefined index. And here's the desired ...

 javascript                     2 answers                     51 view
 2018-10-22         Gavin

How to bind on click event on dynamically created button in Angular 6?

I am trying to create a dynamic button with an onclick event. The showname() defined the on same Component.ts. But there is no response on clicking the button Component.tscreatetooltip() { this.tooltip = document.createElement('div'); this.tooltip.style.cssText = 'position:absolute; background:black; color:white; padding:4px;z-index:10000;' + 'border-radius:2px; font-size:12px;box-shadow:3px 3px 3px rgba(0,0,0,.4);' + 'opacity:0;transition:opacity 0.3s'; this.tooltip.innerHTML = '<button id="popup" (click)="showname()" >Copy!</button>'; document.bo...

 javascript                     3 answers                     93 view
 2018-10-22         Spencer

This version of CLI is only compatible with Angular version 5.0.0 or higher error

I already had angular project that ran in 4 version. While installing new project, unfortunately i have installed 6 version of angular cli. This throw me an error 'Your global Angular CLI version is greater than your local version' while running ng serve command in old project that ran in 4 version. Again i tried to update my anglar local version. But now i have got an error This version of CLI is only compatible with Angular version 5.0.0 or higher. My package.json is following: { "name": "authority-client", "version": "0.0.0", "license": "MIT", "scripts": { "ng": ...

 javascript                     3 answers                     93 view
 2018-10-22         Dunn

How to capture regex greedily based on different situation?

Currently, I am trying to implement string interpolation for my language. The string interpolation looks something like thislet x = " Baby"let message = "Hello $(x)"My current regex to capture interpolated expression is const regex = /[$][(].*?[)]/g;However, the regex above works well with non-bracketed expressions, but it does not work properly when the interpolated expression have brackets, for example:let message = "My number is $(square(1+2))"// the captured group would be `$(square(1+2)` , which is missing a bracketI could not use greedy quantifiers, if not it will n...

 javascript                     1 answers                     29 view
 2018-10-22         Miles

zoom image on mouse scroll in angular4?

I have a piece of code which will zoomin/out on mouse scroll as shown below<!DOCTYPE html><html><body><script src='https://www.cssscript.com/demo/image-zoom-pan-mouse-interactions-zoomnpan/zoomnpan.js'></script><style>#demo { width: 460px; height: 250px; background-image: url(https://unsplash.it/3000/2000/?random); background-repeat: no-repeat; background-position: 50% 50%;}</style><div id="demo"></div><script>var p;function enable(){ p = new ZoomNPan(demo); p.minScale = 100;}enable();</script></bod...

 javascript                     2 answers                     51 view
 2018-10-22         Verna

Promise with Javascript

I'm struggling to understand Promise but it's really difficult for me.it makes me crazy, I would appreciate your helps.this is a code and I want "console.log(data)" after Recommend function finishedbut the result is undefined.What should I do? many thanksThis is app.jsvar _promise = function () { return new Promise((resolve,reject) => { var data = getJS.Recommend(req.query.User_id) resolve(data) }).then(function(data) { console.log(data) }) _promise();}})this is RecommendPost.jsexports.Recommend =(myId)=>{ var posts=[] User.find...

 javascript                     4 answers                     92 view
 2018-10-22         Ella

React handle form submit after being redirected by server (with data )?

React front-end submits a form (POST) which is sent to the backend. This server then responds with a js object which contains html (I thought it was supposed to redirect)?How am I supposed to redirect the user to the page that was received? For example if I curl -X POST api.example.com the api, it returns pure html like this:<html>...</html>When using postman, it automatically renders this html. How am I supposed to deal with this in React? If you use NodeJS + express Example: http.get('*',function(req,res){ res.redirect('/'+req.url);})https://expressjs....

 javascript                     2 answers                     94 view
 2018-10-22         Bridget

how to get javascript class properties list

I have javascript this class :class Student { constructor(name, birthDate) { this.name = name; this.birthDate = birthDate; } get age() { return 2018 - this.birthDate; } display() { console.log(`name ${this.name}, birth date: ${this.birthDate}`); }}console.log(Object.getOwnPropertyNames.call(Student));The issue is that you're using Object.getOwnPropertyNames wrong. You don't need to use call on it, you just call it.* And you need to pass an instance of Student; the class object itself doesn't have any properties. The properties a...

 javascript                     1 answers                     19 view
 2018-10-22         Louis

JavaScript - Accessing a child variable in a parent class

In JavasScript, is it possible to define a variable in a child class, then access it in a parent class? I imagine the child class would look something like this:export default class ChildClass extends ParentClass { constructor() { this.path = 'register'; }}A use-case scenario is an HTTP service class as the parent that contains general, reusable methods and a child class that defines the exact route that will be accessed. Assuming it's possible, how could I then access this.path in the parent class? You don't need to do anything special, it just works.As men...

 javascript                     1 answers                     21 view
 2018-10-22         Hayden

Check and add for property in object of arrays

I have an object/output in a very specific format detail below:result = AB: [ 0:{Name: "Tom", team:"Spirit", position: "Defender", score: 22 } 1:{Name: "Paul", team:"Vikings", position: "center" } 2:{Name: "Jim", team:"United", position: "Wing", } 3:{Name: "Greg", team:"Crusaders", position: "Fullback", score: 54} 4:{Name: "Tim", team:"Vikings", position: "Fullback", score: 77 } ]CD: [0:{...},1:{...},2:{...},3:{...},4:{...}]EF: [0:{...},1:{...},2:{...},3:{...},4:{...}]GH: [0:{...},1:{...},2:{...},3:{...},4:{...}]The result has nested arrays. On some outputs t...

 javascript                     1 answers                     25 view
 2018-10-22         Dolores

I'm trying to figure out how to add the values in an object using a function

Here's the code. I left the function block blank because I'm stumpedfunction getSummedAge(people) {}const examplePeopleArray = [ { name: 'John', age: 10 }, { name: 'Jack', age: 20 }, { name: 'Jane', age: 25 }];console.log(getSummedAge(examplePeopleArray)); Checkout the Array.reduce method! It's purpose is to basically reduce an array into a single value, which I believe is what you're trying to do here: Array.reduce() MDNHere's a little example of how you might use it in this context function sumAllApplesIn(baskets){ return baskets.reduce((accumulator, curre...

 javascript                     2 answers                     26 view
 2018-10-22         Sally

Get value of key from object using variable and object

I'm trying to get a value from my object using variable and another object.The first variable worked very well, but is get stuck at the second one and tried a lot of things without success.console.log(data.data.mengsels_data['mengsels_label_'+counter_i]);console.log(data.data.mengsels_data['mengsels_label_'+counter_i[sessionStorage.language]]);console.log(sessionStorage.language);The first line returns;Object {nl: "April", en: "April", de: ""}Second line returns;undefinedThird line returnsnlI need to get 'April'Added laterIn the example below data is retrieved with ajax cal...

 javascript                     2 answers                     25 view
 2018-10-22         Benjamin

JavaScript Promise - Object defined but specific property undefined

I'm trying to get data from firebase. I receive the data as an Object and it shows the data I want. However when I try to get a specific value from an Object property it says it's undefined. What am I doing wrong or what am I missing?export const createChat = () => { return async dispatch => { dispatch({ type: CREATE_SINGLE_CHAT }); const creator = firebase.auth().currentUser.uid; const userRef = firebase.database().ref(`/users/${creator}`); const currUser = await userRef.once('value'); console.log(currUser); console.log(currUser.name); };};Here is...

 javascript                     1 answers                     29 view
 2018-10-22         Norma

Set multi select options from stored localstorage values

I am trying to set multiple select options to selected, based on the corresponding localstorage value.Storing the values in an array in localstorage is working, but I need help selecting the options in a form based on these values..The values in localstorage are collected from checkboxes like so:jQuery(document).ready(function(){ var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {}, checkboxes = jQuery(".add-selectie :checkbox"); checkboxes.on("change", function(){ checkboxes.each(function(){ checkboxValues[this.id] = this...

 javascript                     1 answers                     41 view
 2018-10-22         Melissa

Is it possible to show navbar for a web resource in Dynamics CRM?

I'm wondering if it's possible to show the navbar for Dynamics CRM when you're loading a web resource directly with url(/WebResources/WebResource?data=exampleData). I have tried with /WebResources/WebResource?data=exampleData&web=true but no luck.I have been able to show the navbar for my web resource when adding it to the navigation menu and loading it with this url(/main.aspx?page=Area&area=NewSubArea&web=true). But I haven't been able to pass data in the url with this solution. Unfortunately navBar option is available only for Xrm.Navigation.openForm...

 javascript                     1 answers                     40 view

Page 2 of 8971  |  Show More Pages:  Top Prev Next Last