Javascript ajax整数和字符串的post数组
我必须用ajax将整数数组和字符串值发送到php。 如何做到这一点,以及如何在php端获取这些值Javascript ajax整数和字符串的post数组,javascript,php,arrays,ajax,Javascript,Php,Arrays,Ajax,我必须用ajax将整数数组和字符串值发送到php。 如何做到这一点,以及如何在php端获取这些值 // values to be send var nums = [1,2,3,4]; var method = "delete"; $.ajax({ url: "ajaxcalls.php", type: "GET", dataType: "json", data: ???, contentType: 'application/json; charset=u
// values to be send
var nums = [1,2,3,4];
var method = "delete";
$.ajax({
url: "ajaxcalls.php",
type: "GET",
dataType: "json",
data: ???,
contentType: 'application/json; charset=utf-8',
});
// ajaxcalls.php
<?php
???
?>
//要发送的值
var nums=[1,2,3,4];
var method=“delete”;
$.ajax({
url:“ajaxcalls.php”,
键入:“获取”,
数据类型:“json”,
数据:???,
contentType:'application/json;charset=utf-8',
});
//ajaxcalls.php
只需将对象中的数据传递给$。ajax
和jQuery将为您序列化数据。在PHP中,您只需通过$\u GET super global检索数据
// values to be send
var nums = [1,2,3,4];
var method = "delete";
$.ajax({
url: "ajaxcalls.php",
type: "GET",
data: {"nums": nums, "method": method}
});
<?php
$numArray = $_GET['nums'];
$method = $_GET['method'];