[英]Passing data to Php with Jquery Ajax
I want to pass two input data to PHP with JQuery ajax I read about json , serialize and similar but I couldn't quite get a grip around it. 我想用JQuery ajax将两个输入数据传递给PHP,我读到有关json ,序列化之类的东西,但是我不太了解它。 I got:
我有:
<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>
And also what do I need on PHP file because I only got this. 以及我在PHP文件上需要什么,因为我只有这个。
$name=($_GET['']);
$surname =
echo($name) ;
endif;
function callAjax() {
// Get values to send to server
var domain = $('#domain').val();
var domain1 = $('#domain1').val();
$.ajax({
type: "GET",
cache: false,
url: 'getip.php',
data: {
domain: domain,
domain1: domain1
}
And in php you'll get it as 在PHP中,您将获得
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
Docs: http://api.jquery.com/jQuery.ajax/ 文件: http : //api.jquery.com/jQuery.ajax/
$.ajax({
type: "GET",
cache: false,
url: 'getip.php',
data = {
'domain': $('#domain').val(),
'domain1': $('#domain1').val()
};
)};
And in you php file php you can get data with : 在您的php文件php中,您可以通过以下方式获取数据:
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
Try this:- 尝试这个:-
<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()}
});
In your php file get it like this:- 在您的php文件中,如下所示:-
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
Note:- Please try to read jquery a bit. 注意:-请尝试阅读一下jquery。 It will help you.
它会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.