Home >Backend Development >PHP Tutorial >html-怎么样通过ajax把参数传递给上级目录 的php文件?

html-怎么样通过ajax把参数传递给上级目录 的php文件?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-02 11:33:311100browse

phphtmljquery

目录结构如下:www/a/b/c;
html文件在c目录下,要在这个html文件中通过jquery的ajax方式把act=remove&id=2
传给b目录下的一个php文件,
可以这么做吗?
如果可以
jquery中的ajax函数要怎么写? 具体的就是那个url参数该怎么写?
html文件代码:

<code>             <script type="text/javascript" src="jquery-1.11.2.js"></script>                  PHONE:<input type="text" name="phone" id="phone">        ORDER:<input type="text" name="order" id="order">        ZIP:<input type="text" name="zip" id="zip">        <input type="submit" name="submit" value="submit" onclick="dd()">        <script language="javascript" type="text/javascript">        function dd(){$.ajax({      url:"../2.php",            type:"GET",            data:{                    phone:$("#phone").val(),                    zip:$("#zip").val()            },        success:function(data){                alert(data);      }         } );}</script></code>

php代码:

<code><?php print_r($_GET);</code></code>

php文件在根目录下,html文件在根目录下的一个文件夹里

这是根目录,2.php在这个目录下
图片说明

html文件在这个目录下
图片说明

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