Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 21 2018 17:11
    @MadLittleMods banned @OmarAlmaqtri
  • Jun 05 2018 23:13
    @MadLittleMods banned @LWSS
  • May 25 2018 16:50
    @MadLittleMods banned @TheRedstoneTaco
Stephen James
@sjames1958gm
Possibly not
dimtabu
@taburetkin

@shekharramola

var xhr = $.ajax({...});
mySuperFunction(xhr);

function mySuperFunction(xhr) {
  xhr.then(() => .... );
}

what wrong with this approach?

Shekhar Ramola
@shekharramola
@taburetkin , this is cool but I try to follow DRY(Do not repeat) wherever possible.
dimtabu
@taburetkin
Its not clear what do you want to achieve
Shekhar Ramola
@shekharramola
am I doing anything wrong?
 addDynamicHTML('particularId', data.data[i].title);
function addDynamicHTML(selectedElementId, template) {
  console.log(selectedElementId);
  console.log(template);
  if (document) {
    console.log(document.getElementById(selectedElementId));
    document.getElementById(
      JSON.stringify(selectedElementId)
    ).innerHTML = template;
  }
}
 console.log(document.getElementById(selectedElementId));
above statement will say, it is null though it shouldn't be. just a plain synchronous function
dimtabu
@taburetkin
you can work with dom by js only after dominteractive event
and for some browsers after dom loaded event
Shekhar Ramola
@shekharramola
I am creating dom element dynamically.
like this
    var tdDeliveryTerms = createElement('td');
    addClass(tdDeliveryTerms, 'tableTitle');
    addClass(tdDeliveryTerms, 'fontSize12');
    var particaularDiv = divCreator();
    addClass(particaularDiv, 'fontMedium');
    addClass(particaularDiv, 'title');
    particaularDiv.setAttribute('id', 'particularId');
    console.log(particaularDiv);
    addDynamicHTML('particularId', data.data[i].title);
dimtabu
@taburetkin
document in all browsers is not falsy. so your if is useless
if your DOM not ready, you get null, so you have to wait for document completely loaded for working with dom.
Shekhar Ramola
@shekharramola
couldn't attach an event listener due to performance issue so I tried another way. seems like working.
function addDynamicHTML(selectedElement, template) {
  console.log(selectedElement);
  console.log(template);
  var text = document.createTextNode(template);
  selectedElement.appendChild(text);
}
dinesh
@1532j0004kg

@1532j0004kg
getJson inside for loop issues
I found some articles but still the answer is not getting correctly because the value is keep on changing ...

for example: sometimes 0 1 and sometimes 1 0

Can anyone tell how to solve!
lilalienx
@lilalienx
Hello community new to the room frontend dev html, css, bootstrap, javascript nerd any one doing a live coding in JS i am down to watch and get into projects.
jasper917
@jasper917
Hello community new to the room frontend dev html, css, bootstrap, javascript nerd any one doing a live coding in JS i am down to watch and get into projects.
dinesh
@1532j0004kg
All are I hope @jasper917
syedsimanta03
@syedsimanta03
OS related question what u prefer for web and app dev- apple Mac os or Linux?
EuphoricPenguin
@EuphoricPenguin
@syedsimanta03 Since I mostly dabble in NodeJS, all platforms are equally suited. Linux is a good option for server-side, and Windows has worked fine for me as my dev platform.
syedsimanta03
@syedsimanta03
windows keep crashing all the time when working on android dev
@EuphoricPenguin should I install linux on external HDD or on a virtual box?
EuphoricPenguin
@EuphoricPenguin
@syedsimanta03 You could always dual boot on your existing HDD if you have enough space.
EuphoricPenguin
@EuphoricPenguin
If not, an external HDD for vo
*boooting is ok.
VMs can be convenient, but it depends on what you want to do. If you need to flash stuff to boards/other hardware level stuff, the software can complicate things a great deal.
syedsimanta03
@syedsimanta03
@EuphoricPenguin I will then install linux on my HDD. So basically the HDD will be devided into 2 partitions. 300gb for linux development. 700gb for my necessary files
dimtabu
@taburetkin
Does anyone knows how to avoid this behavior?
https://s.codepen.io/dimatabu/debug/YzKpZGV/bZMQWELzJQYA - try it with chrome, its a codepen in debug mode
in codepen frame there is no such issue: https://codepen.io/dimatabu/pen/YzKpZGV
ns26
@ns26

Hey guys, looking for a JS medior/senior to give me some pointers on a script. The script is in a private/local (non-store) Chrome extension that highlights certain iframes with CSS in try/catches (to bypass some basic security issue). Usecase is an online CRM system called Exact.

Link to the main script here: https://pastebin.com/e3w8rXqX

What I'm trying to add is: if value 123 is found while highlighting ID list A then also highlight ID list B but only with a border-property. In the scenario where there is the same ID in list A & B it needs to properly apply both highlight functions.

I've tried all day yesterday to make it happen in numerous of ways but without any luck. I'm just a student that picked up a slightly overambitious internship project :p I can do basic debugging but I'm definitely a junior..

Mahi
@arbitrarymahi
HI
How do I wait till my XHR returns the response? Currently I get reuest.status = 0 and the code execution moves on but I want to wait until response is recieved.
Stephen James
@sjames1958gm
You don’t. Or at least shouldn’t. Use call back functions
Your in the browser should handle asynchronous behavior
Mahi
@arbitrarymahi
Actually i am calling an API but it has limit 10 fixed so i am using the XHR call inside a forloop but before i recieve the response the for loop iteration executed again and again
is that a good practice or else what should be the best solution in this case?
Stephen James
@sjames1958gm
You don’t want to have your js wait for responses as that will block your browser and is bad user experience. If they can run in parallel then you can assign a function to the onreadystatechange event property and handle each response as it occurs. This would be after the for loop completes. If you have specific code that should run after all the responses you would have to keep track of the responses and call that code from the code handling the last response.
Also, your code should not depend on the parallel responses coming back in the same order as you sent them.
If they cannot be parallel then each callback would invoke the next xhr request
Mahi
@arbitrarymahi
xhr.open(method, url, true);
xhr.onreadystatechange = function () {
// Begin accessing JSON data here
  var count = 0
  var data = JSON.parse(xhr.response)
  //var data = JSON.parse(xhr.responseText)
  if (request.status >= 200 && request.status < 400){
  console.log('data is: \n',data.records)}
else {
    console.log(request.status)
  }
  };
xhr.send()
I have written this code and it gets the response but due to some reason it is logging to the console twice.
Stephen James
@sjames1958gm
Is it hitting both console.log?
dimtabu
@taburetkin
if it logs twice then it means that onreadystatechange called two times
I just put my Node.js authentication boilerplate on Github. Check it out.
ptmhpp
@ptmhpp

Hi Guys…..
I have a javascript file and in that there are some functions defined in it.
How can i get all the function name defined in that particular js file in an array of string

for example js file looks something like this

function getabc1() {
//block of code
}
function getabc2() {
//block of code
}
function getabc3() {
//block of code
}

I need all the 3 functions name defined in this particular js file.
Only name of function
It will be great help if someone can help me on this.

dimtabu
@taburetkin
short: process the js file in some other runtme, read it as text and find something by pattern and store it somehow somewhere.
But i believe you are doing something certain and your question is partial.
I believe that there is more easy/better ways exists to achieve what you really want
lilalienx
@lilalienx
any 1 here doing stream in programming javascript? i would love to watch and learn i am level 5 of 10 in javascript thank you community.
Braulio
@bab2683
@lilalienx what do you mean you are level 5 of 10 in javascript?