Getting value GET OR POST variable using JavaScript?

Peter MortensenMohit Jain提出了一个问题:Getting value GET OR POST variable using JavaScript?,或许与您遇到的问题类似。

回答者Igor Zinov'yev给出了该问题的处理方式:

You can't get the value of POST variables using Javascript, although you can insert it in the document when you process the request on the server.

<script type="text/javascript">
    window.some_variable = '<?=$_POST['some_value']?>'; // That's for a string
</script>

GET variables are available through the window.location.href, and some frameworks even have methods ready to parse them.

希望本文对你有帮助,欢迎支持JavaScript中文网