Asynchronous cross-domain POST request via JavaScript?

后端 未结 5 1868
一整个雨季
一整个雨季 2020-12-24 09:37

I could just create a form and use that to do a POST request to any site, thing is the FORM method isn\'t asynchronous, I need to know when the page has finished loading. I

5条回答
  •  遥遥无期
    2020-12-24 10:19

    You can capture the onload event of an iframe. Target your form to the iframe and listen for the onload. You will not be able to access the contents of the iframe though, just the event.

    Try something like this:

    
    
    
    ...

    script block:

    var loadComplete = 0
    function loaded() {
        //avoid first onload
        if(loadComplete==0) {
            loadComplete=1
            return()
        }
        alert("form has loaded")
    }
    

提交回复
热议问题