05-27-2022, 03:00 AM
Sorry for the late reply, somehow I missed this.
It's hard to know what's going on because it is kind of complicate to figure out from the code only...
Why are you using the hidden input to pass the data to the callback? Can't you pass the string directly to it?
What caught my eye is this piece of Javascript code:
' addHiddenInput("JSONRESPONSE",JSON.stringify(orderData, null, 2)); ' + sLineBreak +
' ajaxCall("JsonPayPalResponse","&TipoAbbonamento='+ TipoAbbonamento.ToString +'",false); //abbonamento personale ' + sLineBreak +
' }); ' + sLineBreak +
addHiddenInput changes the DOM and ajaxCall() fires directly. As you mentioned above, seems that the ajaxCall needs the hidden input, is that so?
From my experience when adding nodes to the DOM sometimes code that runs immediately after that may or may not perceive the new node.
Is like the browser effectively updates the DOM tree only after calling the ajaxCall() line (it's like they were executed out of order).
I would start trying to call the ajaxCall() from inside a setTimeout call, something like:
setTimeout(function(){ajaxCall(bla bla bla)}, 10);
and see how it goes.
It's hard to know what's going on because it is kind of complicate to figure out from the code only...
Why are you using the hidden input to pass the data to the callback? Can't you pass the string directly to it?
What caught my eye is this piece of Javascript code:
' addHiddenInput("JSONRESPONSE",JSON.stringify(orderData, null, 2)); ' + sLineBreak +
' ajaxCall("JsonPayPalResponse","&TipoAbbonamento='+ TipoAbbonamento.ToString +'",false); //abbonamento personale ' + sLineBreak +
' }); ' + sLineBreak +
addHiddenInput changes the DOM and ajaxCall() fires directly. As you mentioned above, seems that the ajaxCall needs the hidden input, is that so?
From my experience when adding nodes to the DOM sometimes code that runs immediately after that may or may not perceive the new node.
Is like the browser effectively updates the DOM tree only after calling the ajaxCall() line (it's like they were executed out of order).
I would start trying to call the ajaxCall() from inside a setTimeout call, something like:
setTimeout(function(){ajaxCall(bla bla bla)}, 10);
and see how it goes.

