Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Jquery Ajax将数据传递给Php_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript 使用Jquery Ajax将数据传递给Php

Javascript 使用Jquery Ajax将数据传递给Php,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我想用jqueryajax将两个输入数据传递给PHP,我读到了关于json、serialize和类似的内容,但我不能完全掌握它。我得到: <p><input type="text" id="domain"></p> <p><input type="text" id="domain1"></p> <button id="order">Search</button> <script type="t

我想用jqueryajax将两个输入数据传递给PHP,我读到了关于json、serialize和类似的内容,但我不能完全掌握它。我得到:

<p><input type="text" id="domain"></p>
<p><input type="text" id="domain1"></p>
<button id="order">Search</button>

<script type="text/javascript">
    function callAjax() {
        $.ajax({
            type:  "GET",
            cache: false,
            url:   'getip.php',
            data:  ???
    });
</script>
在php中,您将得到

$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
文件:

在php中,您将得到

$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
文件:

在php文件php中,您可以通过以下方式获取数据:

$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
在php文件php中,您可以通过以下方式获取数据:

$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
试试这个:-

<p><input type="text" id="domain" name = "domain"></p>
<p><input type="text" id="domain1" name ="domain1"></p>
<button id="order">Search</button>
function callAjax() {

$.ajax({
    type: "GET",
    cache: false,
    url: 'getip.php',
    data:{domain: $('#domain').val(),domain1: $('#domain1').val()}
});
注意:-请尝试稍微阅读jquery。它将帮助您。

尝试以下方法:-

<p><input type="text" id="domain" name = "domain"></p>
<p><input type="text" id="domain1" name ="domain1"></p>
<button id="order">Search</button>
function callAjax() {

$.ajax({
    type: "GET",
    cache: false,
    url: 'getip.php',
    data:{domain: $('#domain').val(),domain1: $('#domain1').val()}
});

注意:-请尝试稍微阅读jquery。它将帮助您。

显示您的html代码以及所有html代码。有两个输入的Body,我正在学习这些东西,所以我没有太多工作要做。1)您需要链接到jQuery来加载库。2.)您需要将javascript/jQuery放在脚本标记或.js文件中并链接到它。3.)您需要将函数放入
$(document).ready(function(){//code here})
$(函数(){//code here})你真的应该复制/超过你的html页面和php页面的全部内容,这会有很大帮助,因为像这样,我们甚至不知道是否包含jquery库,或者是否调用
callAjax
func@Bob0t这就是为什么我没有编辑文章并添加脚本标记,因为现在您可能已经将源代码更改为用户3187715没有/可能没有的代码。用户3187715可能不知道您需要将javascript放入脚本标记中,并且可能没有注意到您的编辑。显示html代码也显示所有html代码。有两个输入的Body,我正在学习这些东西,所以我没有太多工作要做。1)您需要链接到jQuery来加载库。2.)您需要将javascript/jQuery放在脚本标记或.js文件中并链接到它。3.)您需要将函数放入
$(document).ready(function(){//code here})
$(函数(){//code here})你真的应该复制/超过你的html页面和php页面的全部内容,这会有很大帮助,因为像这样,我们甚至不知道是否包含jquery库,或者是否调用
callAjax
func@Bob0t这就是为什么我没有编辑文章并添加脚本标记,因为现在您可能已经将源代码更改为用户3187715没有/可能没有的代码。用户3187715可能不知道您需要将javascript放入脚本标记中,并且可能不会注意到您的编辑。当我尝试在jquery上阅读文档时,就像阅读阿拉伯语或汉语一样,我总是需要看到真实的示例,仅凭我的学习风格,我将尝试以下方法:)。看看它是如何工作的,然后把它标记为你的答案。这有助于其他人找到解决方案。哦,我想我做到了:)。当我尝试在jquery上阅读文档时,就像阅读阿拉伯语或汉语一样,我总是需要看到活生生的例子,就我的学习风格而言,我会尝试一下:)。看看它是如何工作的,然后把它标记为你的答案。这有助于其他人找到解决方案。哦,我想我做到了:)。
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];