【发布时间】:2011-09-04 02:07:53
【问题描述】:
我正在使用 AJAX 将一些数据放入我的数据库中。我正在使用 JSON 将数据提交到 PHP 页面。我正在使用 POST 请求。您可以将 POST 变量之一设置为数组吗?下面我有完整的 AJAX 请求,但这里是我将数据的两部分设置为数组的部分:
"content[]" : testContentArray,
"content_attr[]" : testContentAttributes,
以下是我的完整 AJAX(使用 jQuery):
$.ajax({
type: "POST",
url: "../includes/create_test_main.ajax.php",
data: {"tags" : $('#testTags').val(),
"title" : $('#testTitle').val(),
"subject" : $('#testSubject').val(),
"description" : $('#testDescription').val(),
"content[]" : testContentArray,
"content_attr[]" : testContentAttributes,
"user_id" : user_id},
success:
function(testId) {//redirect Page
window.location.href = "http://localhost/nvr_forget/public_html/test/" + testId + "/";
}
});
};
如果这是这样做的方法,我将如何在 PHP 端处理它?我应该将 $_POST 变量作为普通数组处理吗?
【问题讨论】:
标签: php ajax arrays jquery post