ajax 데이터 전송

Tag : PHP
  
                

<?php

function get_member_opt_view($fild, $mb_id, $mb_hp) 
{ 
  global $g5; 
$sql = "select * from g5_member where mb_level > '2' and mb_level < '5' ORDER BY mb_1 DESC"; 
    $result = sql_query($sql); 
    for ($i=0; $row=sql_fetch_array($result); $i++) 
    { 
        $str .= "<option value='$row[mb_id]'"; 
        if ($row[mb_id] == $fild or $row[mb_id] == $mb_id) $str .= " selected"; 
        $str .= ">{$row[mb_1]}- {$row[mb_name]} / {$row[mb_3]} / {$row[mb_4]}</option>"; 
    } 
    return $str; 
} 
?>
          <input type="hidden" name="ca_name" id="mb_id" value="">  
          <input type="hidden" name="wr_to_mail" id="mb_email" value=""> 
          <input type="hidden" name="wr_to_name" id="mb_name" value=""> 
          <input type="hidden" name="wr_to_mb_3" id="mb_3" value=""> 
          <input type="hidden" name="wr_to_mb_4" id="mb_4" value=""> 
          <input type="hidden" name="wr_to_hp" id="mb_to_hp" value=""> 
          <input type="text" name="mb_hp" id="mb_hp" value="" placeholder="담당자 선택하세요" disabled="disabled" style="width:150px;"> 
            <script>
            function target_mb_select()
            {
            	if($("#target_mb").val()=='')
            	{
            		writeform_reset();
            	}
            	else
            	{
            		$.ajax({
            			url: './ajax_log.php',
            			type: "GET",
            			data: "mode="+$("#target_mb").val(),
            			datatype: "html",
            			success: function(data){
            				var tmp=data.split('|');
                                $("#mb_id").val(tmp[0]);
                                $("#mb_hp").val(tmp[1]);
                                $("#mb_email").val(tmp[2]);
                                $("#mb_name").val(tmp[3]);
                                $("#mb_3").val(tmp[4]);
                                $("#mb_4").val(tmp[5]);
                                $("#mb_to_hp").val(tmp[6]);
            			},
            			error: function(){
            				alert("데이터를 가져오는데 실패했습니다.");
            			}
            		});
            	}
            }
            </script>

//ajax_log.php

<?php
include_once('./_common.php');
$sql = "select * from g5_member where mb_id = '$_GET[mode]'"; 
$result = sql_query($sql); 
$row=sql_fetch_array($result);
?>
<?=$row['mb_id'];?>|<?=$row['mb_hp'];?>|<?=$row['mb_email'];?>|<?=$row['mb_name'];?>|<?=$row['mb_3'];?>|<?=$row['mb_4'];?>|<?=$row['mb_hp'];?>