Home  >  Article  >  Backend Development  >  AJAX传递参数,PHP无法获取解决思路

AJAX传递参数,PHP无法获取解决思路

WBOY
WBOYOriginal
2016-06-13 10:23:23888browse

AJAX传递参数,PHP无法获取
AJAX代码如下:

JScript code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->type:'POST',url:'../php/a.php?ID='+'abc',success: function(data){    alert(data);}

PHP代码如下:
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->echo $_GET['ID'];

为什么js文件能弹出显示‘abc'的对话框,PHP页面却什么也没有呢?

------解决方案--------------------
什么“什么也没有”? 你怎么访问的。url上带ID了吗?
------解决方案--------------------
不可能。既然ajax都能获取到。说明php返回了值。/a.php?ID=33 是这样访问的吗?
------解决方案--------------------

ajax.html
HTML code
            <meta charset="gb2312">        <title></title>            <script src="http://code.jquery.com/jquery-latest.js"></script>        <style>                </style>                        <script>            $.ajax({                type:'POST',                url:'index.php?ID='+'abc',                success: function(data)                {                    alert(data);                }            })        </script>    <br><font color="#e78608">------瑙e</font>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn