게시판 검색 결과 ajax로 더보기 채택완료

게시판 검색을 하면

bo_table=게시판&sca=카테고리 ... 이런식으로 있는데

이 값들을 get으로 ajax에 보냈는데 작동을 안하네요 ...


보내는건 아래와 같이 보냈습니다.

Copy
var _tempUrl = decodeURIComponent(window.location.search.substring(1)); //url에서 처음부터 '?'까지 삭제        var _tempArray = _tempUrl.split('&'); // '&'을 기준으로 분리하기        var _sca = _tempArray[1].split('=');   //sca자르기        var _sop = _tempArray[2].split('=');    //sop자르기        var _sfl = _tempArray[3].split('=');    //sfl자르기        var _stx = _tempArray[4].split('=');    //stx자르기     if(document.getElementById('scr_content'+btn) == null){        $.ajax({            url : "경로",            type : "get",            dataType : "json",            data :{                no: btn,                board : _board[1],                sca : _sca[1],                sop : _sop[1],                sfl : _sfl[1],                stx : _stx[1]            },


ajax.more_read.php에는

Copy
include_once('../../../../common.php');$link = mysqli_connect("", "", "", "");$board = $_GET['board'];$sca = $_GET['sca'];$sop = $_GET['sop'];$sfl = $_GET['sfl'];$stx = $_GET['stx'];$total_sql = "select count(*) as total from {$g5['write_locationboard_table']} where wr_is_comment = 0";$total_row = mysqli_query($link, $total_sql);$total_result = mysqli_fetch_array($total_row);$first_rows = $_GET['no'];	//시작점if($_GET['no'] == null){	$first_rows = 0;}$end_rows = $first_rows + 10;	//마지막점$rows = $total_result[0];	//전체 글 수// $get_sort = $_GET['sort'];// if($get_sort == "good"){// 	$sort = wr_good;// }else if($get_sort == null || $get_sort == "new"){// 	$sort = wr_datetime;// }else if($get_sort == "hit"){   //조회 순// 	$sort = wr_hit;// }else if($get_sort == "cmt"){   //댓글 순// 	$sort = wr_comment;// }else{// 	$sort = wr_datetime;// }$sql_search = get_sql_search($sca, $sfl, $stx, $sop);if($sca || $stx){	$sql = "select distinct wr_parent from {$g5['write_locationboard_table']} where {$sql_search} and wr_is_comment = 0  limit {$first_rows}, {$end_rows}"; //order by {$sort}	$result = sql_query($sql);	for($k=$first_rows; $k<$end_rows; $k++){		$row = sql_fetch_array($result);		$row_sql = "select a.*,b.bo_subject,b.bo_table, CASE WHEN c.wr_id IS NOT NULL THEN c.bf_file ELSE NULL END AS bf_file		FROM {$g5['write_locationboard_table']} a		LEFT JOIN {$g5['board_table']} b ON a.wr_10 = b.bo_table		LEFT JOIN {$g5['board_file_table']} c ON a.wr_id = c.wr_id AND a.wr_file >= 1 AND c.bf_no=0		WHERE a.wr_is_comment = 0 AND a.wr_id = '{$row['wr_parent']}'  limit {$first_rows},{$end_rows}"; //order by {$sort} desc		$result_last = sql_fetch_array($row_sql);	}	echo json_encode($reslut_last);}// }else{// 	$sql_sort = "select a.*, c.bo_subject, CASE WHEN b.wr_id IS NOT NULL // 	THEN b.bf_file ELSE NULL END as bf_file// 	FROM {$g5['write_locationboard_table']} a // 	LEFT JOIN {$g5['board_file_table']} b // 	ON a.wr_id = b.wr_id AND a.wr_file >= 1 AND b.bf_no=0// 	LEFT JOIN {$g5['board_table']} c// 	ON a.wr_10 = c.bo_table// 	ORDER BY {$sort} DESC LIMIT {$first_rows},{$end_rows}";// 	$result_sort = mysqli_query($link, $sql_sort);// 	for($k=$first_rows; $k < $end_rows; $k++){// 		$result_last[$k] = mysqli_fetch_array($result_sort);// 	}// 	echo json_encode($result_last);	// }?>


위와 같이 검색에 필요하다 싶은것만 가져왔는데 


어디가 잘못된 걸까요..


에러는 

Uncaught TypeError: Cannot read property 'split' of undefined

var _sop = _tempArray[2].split('=');    //sop자르기


여기 부분을 찍어주는데....


답변 1개

채택된 답변
+20 포인트

var _tempArray = _tempUrl.split('\\&'); // '&'을 기준으로 분리하기 



로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고