One’s going to have more.

Swierenga: When using a promise e.g. $ why wouldn’t an exception cause the promise to go to the fail method? In this case a JSON parsing error?

Manfre: Chrisgeorge: You shouldn’t have to p**** JSON inside an $.ajax callback, but the reason is because there is a boolean contract about the promise you were given and what you application expectes.

Manfre: If the .done or success handler is firing, and producing its own error, that is not an error in the original request.

Grosskreutz: Kuse: The error is actually happening before any of that.

Manfre: It would violate the application contract to then also fire the failure handler

Bresler: Https://

Manfre: The exception happens inside processInitStreamData?

Mendyk: That’s an example, the error is happening upon return of the data, as .done is never reached obviously

Ott: In this case, the JSON being returned is invalid Kuse it has a Nan in it, don’t ask. So the JSON parsing is failing and throwing an exception, but not going to the .fail method

Manfre: I think in this case it’s a legacy decision from long ago. It’s not an issue with the request or response, rather it’s post-processing.

Manfre: Nowadays you’d use .then to create a new promise and proceed to p**** there, which can then fail.

Materna: I’m just curious why/how to make it do so. I looked at overriding ajaxError but that doesn’t seem to sit well with the promise method

Manfre: E.g. fetch.thenJSON.p****.then . use data

Manfre: Fetch response actually has a .json method in this case, but anyway, I think for now you’re stuck with matching jQuery’s model

Kazi: Vadasy can you accept a pm?

Manfre: Overriding it would certainly not help interoperability with other code, or intuition for other peopel working with the code that know jQuery.

Okin: That’s a bit disappointing, but expected since jquery doesn’t really use fetch

Manfre: Its’ do***ented though, for what it’s worth

Manfre: Https://

Manfre: So you may rely on this behaviour.

Kruegel: I may need to, thank you for your help

Manfre: If you expect invalid JSON to be a regular event e.g. from user input a try/catch would be in other. Otherwise it’s kind of expected to throw an exception and bubble up further in your application

Manfre: A last-resort window.onerror handling that provides some basic UI feedback to the user may be useful as well if you’re worried about the UI freezing for an end-user.

Kam: What is the proper method to clone a form elements and have it submit correctly?

Bram: Why are jquery errors so bad? Bleh.

Braverman: Sadtaco: ya it kind of blocks the first iteration by waiting on teh second, and so form

Vanhulle: You mean the recursive loop isn’t accurate because of the blocking nature before it gives another time to loop again? You can use set interval.

Plymel: Sadtaco: What is a proper method to clone form elements and have it submit correctly?

Vadasy: Ceramicskull clarify your question a little.

Reilly: Yea but robert, the input ID’s are causing it to try and submit from the form it was cloned from – so it’s not getting submitted correctly.

Vadasy: You can’t duplicate IDs on a page.

Vadasy: So you’ll need to edit those to be unique.

Vadasy: Also, you’ll probably want .clonetrue or .clonetrue, true

Aukes: Yea, I figured, but I was wondering if there was a proper way of doing it

Vadasy: The “proper” was is to not use IDs in this case.

Vadasy: Why are you cloning the for,?

Ackah: Vadasy: I’m a/b testing a modal, so I wanted to just dynamically add it w/o having to spend to much time re-writing a form for the b variation.

Vadasy: That’s a bad a/b test fwiw.

Vadasy: One’s going to have more overhead, putting it at a slight disadvantage.