« first day (1867 days earlier)      last day (3081 days later) » 

1:00 PM
how can I console.log the content of a formData object?
 
console.log(formData)
 
nope
it just goes 'herp that's a object joe!'
 
expand it
...
 
infact I've only just found an answer which agrees with what I was saying
rlemon ?
 
Alright I'm lost.

Right now: User selects something from a select. Set of 5 fields is displayed based on choice (All exist in dom, show/hide with css). Works fine, whatever.

User wants: Values to persist between choices. Eg, user selects 1, fills in information, selects 2, wants values to fill in inputs for 2.

I can't think of a good way to do this. I'm thinking having another dropdown for the user to select where to copy values from but that seems gross
 
1:01 PM
sorry, not an object
 
you can expand objects to see their contents in a proper debugger (aka chrome)
 
@djsmiley2k console.dir(formData)
 
it goes 'formData'
@Cerbrus Does that actually work, or is this a guess
because I tried that too, and got the same back
 
It does actually work
 
'formData'
k wtf is wrong iwth my script :(
 
1:02 PM
Assuming you are using a somewhat capable browser
 
are you sure you're not logging 'formData' instead of formData
 
Is formData a variable that contains the string "formData"?
 
I've done it before
 
data: myForm,
console.log(myForm);
 
console.log('foo');
 
1:02 PM
it shouldn't be
 
Where do you define myForm?
 
@djsmiley2k is this your actual code??
 
yes, urgh
can't call console.log in the ajax call
 
user3119231
@rlemon I just watched this video and must say: Hell, what I'm doing here in office?
 
user3119231
(Replace doing with watching if you want)
 
1:04 PM
14 mins ago, by djsmiley2k
https://jsfiddle.net/DTcHh/14625/
^^ defining the form etc.
 
What is . doing there at line 3?
 
errrm
being wrong ;D
So called console.log(myForm)
get FormData {}__proto__: FormData
bulk.php:139 Y
expanding the FormData object gives me all the functions it has
but none of the data it contains
 
Then it doesn't contain any data
Are you debugging from that fiddle?
 
@Cerbrus then my $_POST's from the page it goes to are magical
no
 
Good, since there are a lot of syntax errors in there xD
 
1:07 PM
as the $_POST get populated with the data I put into the myForm object
yeah I had to copy paste and then censor the code :/
 
I censor my code as well
 
but now it's all good, maybe
well kind of
I can't access the formData inside the ajax call, but I can access the variables I defined which make up the formData
so I can rebuild the FormData again, if needs be
 
let cuss = "████"; // censored code
alert(`${cuss} you!`);
 
@GeoPhoenix you have got to be kidding me.
 
1:13 PM
@djsmiley2k nope
 
Also, how do they show a 'working prototype'
 
user3119231
If people need programs/bots to talk to instead of other humans, I don't want to live on this planet anymore
 
need a bot to talk to? cleverbot.com
 
if it can learn how to hack military networks .. the dream
 
Uncaught TypeError: Cannot read property 'append' of undefined
 
user3119231
1:16 PM
ask him about the drown boy: ben drowning.
 
property? not function?
myForm.append('key', jiraID);
is what I call, inside the success:
@Maurize The Zelda scarypasta?
 
user3119231
@djsmiley2k cleverbot knows about that... More than you think.
 
Pledge €1,000 or more =>
MY DIGITAL ME =>
Our experts will create a custom digital YOU and release it in December.

#immortality
 
user3119231
 
user3119231
fuck this shit, I'm going shit my pants
 
1:22 PM
I don't understand this stupid success call
my brain hurts
OOOOOO WAIT
 
maybe stop using jQuery
 
That'd be a good start :)
I can call the second ajax after the first one, if it's successful, right?
Is that where I'm going wrong all this time?
I should be doing sequencial ajax calls, rather than one inside the success of the other?
As then, the myForm object, hasn't changed ...
 
Guys, when is ES6 coming out? =)
 
So, inside the ajax call I get a callback of dataS
can I access that outside of the ajax call, once it's finished?
 
What do you mean?
Well, you can perhaps return the callback to where you call it.
Or perhaps you can store it in the global execution context. (The window object) when you're inside the ajax call execution context.
 
1:28 PM
@HassanAlthaf It's out. It's up to browsers to implement it
 
@Cereal I see, has any browser completely implemented it?
 
Probably not
 
@HassanAlthaf that sounds... possible?
 
@djsmiley2k Yes.
 
Can I take a value given by the success call and store it globally somewhere, if so, anyone got an example?! D:
 
1:29 PM
function sendRequest(type, url, formData) {
    return new Promise((resolve, reject) = > {
        let xhr = new XMLHttpRequest();
        xhr.open(type, url);
        xhr.onload = () => {
			if( xhr.status === 200 ) {
    			resolve(xhr.response, xhr);
    		} else {
				reject({message: xhr.statusText});
            }
    	};
        xhr.onerror = reject;
        xhr.send(formData);
    });
}
sendRequest('GET', urlA, formData).then(data=>{
	return sendRequest('GET', urlB, data.data);
}).then(finalData=>{
untested wrapper + demo
 
@djsmiley2k Yes you can.
 
should work
 
@rlemon ty
trying to understand that now
 
@djsmiley2k I'd like to recommend you to check this out: udemy.com/understand-javascript
 
why do i feel like javascript is constantly trying to have me re-invent the wheel
 
1:31 PM
It's really a good course, and has really given me a good understanding of JS.
 
the js tag wiki has lots of free resources as well
 
user3119231
@djsmiley2k no, JS is constantly trying to make you learn something.
 
Once I see an example I can understand, I'm normally well away
but I keep getting stuck on this
as it's like... wtf why can't I just pass this variable over .... < there
 
user3119231
@rlemon why do you use "let" instead of "var" ?
 
1:32 PM
why would I use var over let?
 
@djsmiley2k you're still thinking that the code is executed sequentially
 
var is function scoped, let is block scoped. you almost never need function scope. embrace let
 
hmmmm yes?
 
user3119231
@rlemon thank you.
 
@Neil I call the ajax call, it can't do anything with success until we have the data back, and we can't continue... until we have the ajax call come back
so yeah, it's suquencial
 
1:33 PM
@rlemon So that means, the let doesn't care about the current execution context? It just cares about the lexical environment of the code?
 
So, 2 days ago, I ordered a LED light and 5 of these: conrad.nl/nl/…
Today, I got a package that could fit the LED light, and in it, there was a tiny plastic bag containing 5 resistors
 
@djsmiley2k if you can't do anything until you get that info back, then it's one thing
but since it is an asynchronous action, you could be doing something in the meantime
 
@Cerbrus sounds about right
 
regardless of whether or not you need to
 
@Neil hmmm
yes
 
1:35 PM
Called the company: Oh, whoops
 
my second section of code can't do anything until we have that result back
 
We'll send the lights again. You can keep the resistors
 
That's why I put hte second bit inside the success of the first one
 
Oh, the LED light will be sent in 9 days...
 
@Maurize real world example:
for( var i = 0; i < 10; i++ ) {
  console.log('inside', i); // i is available here
}
console.log('outside', i) // and here

for( let j = 0; j < 10; j++ ) {
  console.log('inside', j); // j is available here
}
console.log('outside', j) // and NOT here
 
1:36 PM
@djsmiley2k right, that's what you should be doing
 
@GNi33 you will have to wait for 14 days, but then prepare to be annihilated :D
 
user3119231
@rlemon thanks but I already found the difference :)
 
@Neil Ok brill -
 
So, let has block scoping? Or however that's called?
 
focus on what happens when success happens rather than how the hell to get the value once you've sent the request
 
1:36 PM
@Neil So success returns dataS, dataS['key'] needs to be 'added' to the data from the original call
 
@Abhishrek bold statement... we will see :)
but you're probably right... I suck at this game :D
 
@Neil How do I get the data from the original call?
 
when the request returns the data, your page is as you left it once you made the request (assuming you haven't changed it in the meantime)
 
@GNi33 lol just kidding
 
read what currently have before changing it
 
1:38 PM
@Loktar in that case we web developers should celebrate Jan 12.
 
Hm, when is an Origin header actually added by the browser? It seems like it happens only on POST/PUT/DELETE requests?
 
:27128623 ok, odd :/
  data: myForm,   /// here is that form data I was talking about
  success: function (dataS) {
      var jiraID = dataS.key;   /// keep the bit we want
      myForm.append('key', jiraID);    /// Why can't I call append here?
wtf happened to my indenting :(
 
ctrl + k
and you tell me, why can't you call append there?
 
ty :D
The error I get is 'Uncaught TypeError: Cannot read property 'append' of undefined'
Which makes me think myForm isn't.... anymore
 
myForm is a string or an object
it's the data you're passing to the server
 
1:41 PM
it's a FormData object.
 
it isn't a dom object
 
user3119231
myForm = new FormData() :D:D:D
 
FormData {}__proto__: FormData
bulk.php:139 Y
it's FormData :/
@Maurize but I want all the data from the original call in it
Do I have to recreate the entire formdata?
 
maybe myForm isn't what you think it is
it wouldn't give you an error upon sending a request, but server would get weird data
 
user3119231
event(qs(".navigation_menu_wrapper_image_upload"), "change", function(e){
	files = qs(".navigation_menu_wrapper_image_upload").files;
	form = new FormData();
	if (files[0].type.match("image.*")){
		form.append("upload_profile_image", files[0], files[0].name);
		form.append("upload_profile_id", localStorage.getItem("id"));
	}
	ajaxFile(ip + "groupster.php", form, function(e){
		qs(".navigation_menu_wrapper_image").style.background = "url(" + ip + e + "?" + (new Date/1e3|0) + ") no-repeat center";
 
user3119231
1:42 PM
Just an example from my app. Is 110% working. I know: Too less jquery.
 
@Neil the first request works fine..
Only the request inside the success: fails
 
hmm, strange
my advice would be to verify that myForm is the same object as before before making 2nd request
something weird is going on
 
        var myForm = new FormData();
        if(inputRequired == 'Y') {
    	myForm.append('inputRequired','on');
        }
 
Wtf, console.log(typeof null); gives me object
 
@HassanAlthaf Welcome to the wonderful world of javascript
 
1:45 PM
simple form, yet after success: it seems to be not a FormData anymore.
 
in js, object everything you!
 
@Neil That sarcasm. lol
I figured.
 
@Neil how can I check what it is inside a ajax call?
 
@HassanAlthaf nah, not really :P javascript is weird
 
I can't do console.log(myForm);
 
1:46 PM
Everything other than the primitive types are objects.
 
@djsmiley2k put a breakpoint before 2nd ajax call
check what myForm is
 
erm, what's a breakpoint?
 
oh dear
 
K, console.log(myForm); before the second ajax call
lets see
 
1:47 PM
!!google chrome dev tools breakpoint
 
do that, though you should look up an article on how to debug javascript :P
 
Infinitely useful
 
@Cerbrus What is that? :P
 
user3119231
!!google append Files to formData
 
K, immediately after success: it's undefined
myForm no longer exists.
 
@HassanAlthaf It's a short talk about the wtfs of JS
 
Oh, I am following a video course on that topic. lol
 
@djsmiley2k how about this, what is the value of myForm immediately after you've sent the request (before success)?
 
You should have a look at the one I linked. It's quite entertaining (And also only 4 minutes long)
 
1:50 PM
 
@Neil K, this, I don't know exaclty how to check
yes, looking at breakpoints as we speak
 
@djsmiley2k after you send request, not inside success function but after you do $.ajax or $.post whatever you're using
 
@Neil yup
I'm using $.ajax ({
 
user3119231
blame you!
 
({ <-- unibrow / moustache
 
1:53 PM
@djsmiley2k Ok, after that line, try console.log(myForm)
 
yeah it doesn't like it
tells me the . in console.log isn't allowed
Uncaught SyntaxError: Unexpected token .
 
hi
 
@bboni Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
Oh god, did you put it literally after ({
lol
 
user3119231
@bboni welcome!
 
1:57 PM
i have a input text field , with javascript i want to check if the length of the string which has been inputted in the textfield is not bigger then 20. I do that with this: var idValue = document.getElementById(elementId).value;

if (idValue.length <= 20) {
 
user3119231
at first, please send me a scan of your drivers license and your social id number.
 
but it does not go in to the if statement and the inspector shows me that idValue.lenmgth is for example 45
 
user3119231
1. you can use maxlength attribute - 2. you can grab onkeydown event and check if .length is > as 20 then prevent from change
 
@Cereal rofl no LOL
					$.ajax({
						url: 'processToJira.php',
						method: 'POST',
						dataType: 'json',
						data: myForm,
						processData: false,  // tell jQuery not to process the data
						contentType: false,   // tell jQuery not to set contentType
						console.log(myForm),
 

« first day (1867 days earlier)      last day (3081 days later) »