I want to pass it to PHP from the console log.

Asked 2 years ago, Updated 2 years ago, 109 views

Each of them works fine, but no matter how many times I try to pick up AdVideoComplete and connect it, it doesn't work, so I'm asking you a question.

I think it would be better to hand it over to PHP by ajax, but maybe it's possible by javascript, but I've never touched ajax before, so I struggled, but I couldn't solve it.

<script>
function init(api){
if(api){
api.on('AdStarted', function()
{console.log('AdStarted')}
);
api.on('AdVideoComplete', function()
{console.log('AdVideoComplete')}
);
} else
{ console.log('blank');}
}
</script>
function syori() {
document.getElementById('PhotoSpace').src='https://0000.jp/point/img/{point}point.jpg';
varlink= document.getElementById("cmlink");
link.href="./ 〇 ..php?m={md5}";
}

javascript php ajax

2022-09-30 21:42

1 Answers

I would like to know the XMLHttpRequest (Ajax) script, so please refer to it. For more information, see https://developer.mozilla.org/ja/docs/Web/API/XMLHttpRequest.

 var xhr = new XMLHttpRequest();

xhr.open("GET", "0000.php?m=12345", true);

xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded";

xhr.onreadystatechange=function(){
    switch(xhr.readyState){
        case0:
            // State: Uninitialized
            break;
        case1:// state: data transmitting
            break;
        case2:// state:waiting for response
            break;
        case3:// State: Receiving data.
            // console.log(xhr.responseText.length+'bytes');
            break;
        case4:// State: Data received.
            if(this.readyState==XMLHttpRequest.DONE&&this.status==200){
                // post-transmission processing
            }
            break;
    }
}

xhr.send();


2022-09-30 21:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.