Hey there, I have a piece of code that I need some help with.
<button onclick="sbt()" name="step1[save]" type="submit" class="btn-type5 next-btn-form pie" value="Далее">Send</button>
function sbt(){
var phone = document.getElementById('fld1').value;
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}}
xmlhttp.open("GET","host.com/send.php?phone="+phone+"&t="+Date.now(),true);
xmlhttp.send();
}
I'm trying to send this request asynchronously, but when I use xmlhttp.open(...,...,true)
, the request doesn't even reach the server. I've been monitoring it in Google Chrome console. However, if I manually run the sbt()
function from the console, the request goes through just fine. Additionally, if I change to xmlhttp.open(...,...,false)
, it works as expected. Can someone please assist me with this issue? Thank you.