Can't XMLHttpRequest pass the get communication value?

Asked 1 years ago, Updated 1 years ago, 22 views

What I want to do is put a query string in get_ajax_text.php and communicate via get.

I tried to make a test code, but I couldn't even communicate with get in the previous stage.Crying
If you enter the content-type, the post communication was successful.

First of all, please let me know if you can communicate with get or if you can include query strings.

 echo <<HTML
<script>
var login;
vardata={login:1};
varajax = new XMLHttpRequest();
ajax.open('GET','./get_ajax_text.php', true);
//ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajax.send (EncodeHTMLForm2(data));

functionEncodeHTMLForm2(data){
    var params=[];
    for (var name in data) {
        var value = data [name];
        varparam=encodeURIComponent(name).replace(/%20/g, '+')+'='
                + encodeURIC component(value).replace(/%20/g, '+');
        param.push(param);
    }
    return param.join('&');
}
</script>
HTML;

javascript

2022-09-30 14:57

1 Answers

I solved myself.

with null in the ajax.send argument
in ./get_ajax_text.php ./get_ajax_text.php?login=1
Then I could give it to you with get.Thank you, everyone.


2022-09-30 14:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.