I know this seems like already asked question, but I did research and none of the solutions worked for me. I have an javascript array
like this:
[from: "2016-04-01", to: "2016-04-14"]
And I'm sending it via AJAX
on the same page, like so:
data.date=date;
console.log(data.date);
$.ajax({
url: "",
type: "POST",
dataType: "JSON",
data: data,
async: true,
success: function (data) {
}
});
And I put var_dump($_POST['date']);
at the beginning of my page. When I look at Network
took of my browser I can see that request is sent, and my page is listed within Network pages, but $_POST['date']
array is NULL
. And I did put this JS
code within $(document).ready();
, so that cannot be the issue. I just want to get value of this javascript array
into php
variable.
Shouldn't it be [{from: "2016-04-01", to: "2016-04-14"}] ? Isn't it an object inside the array?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.