0
爲什麼這個PHP沒有獲取我的鏈接數組?用jQuery發送JSON AJAX
function check_links() {
$matches = $this->input->get('links');
if($matches == true) {
echo json_encode('matches is true');
} else {
echo json_encode('matches is false');
}
//echo json_encode($matches);
}
的JS
var linksStr = $("#links").val();
var matches = linksStr.match(/\bhttps?:\/\/[^\s]+/gi);
alert(matches.length);
for(var i = 0; i < matches.length; i++) {
alert(matches[i]);
}
var links = JSON.stringify(matches);
$.ajax({
type: 'GET',
dataType: 'json',
cache: false,
data: links,
url: 'publishlinks/check_links',
success:
function(response) {
alert(response);
}
})
什麼'的var_dump($ _ GET)'說明了什麼?或者使用JS調試器,加載了哪個url? – TJHeuvel