jquery + ajax + php 샘플 소스

 
 
제가 허접하게 만들었지만, 샘플 소스 제공해 봅니다. 추천좀 부탁드릴께요~~.
 
[Client Javascript Source]
 
// form과 div의 obj를 넘겨주면, ajax를 실행해서 그 결과 html을 div에 넣어줍니다.
function request_post(form, obj)
{
    var formdata=$(form).serialize();
    //alert("formdata="+formdata);
    $.ajax({
            type: "POST",
            url: "post_server.php",
            data: formdata,
            dataType: "html",
            success: function(data){
                $(obj).html(data);
            },
       });
}
 
// main_cmd,와 sub_cmd, 그리고 value를 인자로 실행시켜서 그 결과를 div와 같은 obj에 삽입
function request_get(main_cmd, sub_cmd, value, obj)
{
    //alert("cmd : " + cmd + ", value : " + value);
    $.ajax({
            url: "get_server.php",
            data: {'main_cmd': main_cmd, 'sub_cmd': sub_cmd, 'value': value},
            dataType: "html",
            success: function(data){
                $(obj).html(data);
            }
       });
}
[Server : PHP 코드]
function ajax_error($code)
{
        global $connect;
        if($connect) my_close($connect);
        header("HTTP/1.0 $code Error");
        exit;
}
 
// 예로.. id 체크하는 것
$m_checkid = $_POST['id'];
 
if( $m_checkid )
{
        $query_string = "select user_id from user_table where user_id = '".$m_checkid."'";
        $return_string = "<font color='green'>사용가능</font>";
        $result = my_query_error($query_string);
        while($row_data =  mysql_fetch_array($result))
        {
                $return_string = "<font color='red'>중복</font>";
        }
        echo $return_string;
}
 
내용은 별로 없지만, 추천좀 해 주세요..
 
프로젝트 의뢰해야 하는데 활동점수가 부족해서 의뢰를 정상적으로 못하고 있습니다. 추천좀 꾹~~
 
|

댓글 6개

일단 츄쳔해써욤
감사합니다.
추천합니다..
추천합니다.
감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,639
14년 전 조회 3,890
14년 전 조회 1,586
14년 전 조회 1,846
14년 전 조회 1,594
14년 전 조회 2,006
14년 전 조회 1,937
14년 전 조회 2,211
14년 전 조회 1,695
14년 전 조회 2,753
14년 전 조회 2,438
14년 전 조회 2,014
14년 전 조회 7,713
14년 전 조회 1,617
14년 전 조회 1,982
14년 전 조회 1,735
14년 전 조회 1,890
14년 전 조회 2,254
14년 전 조회 1,751
14년 전 조회 2,119
14년 전 조회 1,695
14년 전 조회 1,665
14년 전 조회 2,258
14년 전 조회 4,138
14년 전 조회 1,706
14년 전 조회 3,117
14년 전 조회 1,900
14년 전 조회 1,795
14년 전 조회 2,666
14년 전 조회 2,610
14년 전 조회 1,575
14년 전 조회 2,485
14년 전 조회 2,934
14년 전 조회 2,359
14년 전 조회 1,585
14년 전 조회 2,988
14년 전 조회 1,781
14년 전 조회 1,563
14년 전 조회 1,536
14년 전 조회 2,258
14년 전 조회 2,632
14년 전 조회 2,124
14년 전 조회 1,599
14년 전 조회 1,780
14년 전 조회 2,297
14년 전 조회 2,244
14년 전 조회 1,571
14년 전 조회 4,341
14년 전 조회 2,257
14년 전 조회 5,433
14년 전 조회 1,798
14년 전 조회 2,811
14년 전 조회 1,867
14년 전 조회 1,759
14년 전 조회 2,640
14년 전 조회 1,651
14년 전 조회 2,610
14년 전 조회 1,714
14년 전 조회 2,424
14년 전 조회 2,000
14년 전 조회 5,010
14년 전 조회 2,986
14년 전 조회 1,827
14년 전 조회 1,729
14년 전 조회 2,267
14년 전 조회 1,932
14년 전 조회 1,976
14년 전 조회 3,149
14년 전 조회 1,701
14년 전 조회 3,898
14년 전 조회 3,781
14년 전 조회 2,129
14년 전 조회 1,826
14년 전 조회 3,234
14년 전 조회 1,952
14년 전 조회 2,180
14년 전 조회 1,614
14년 전 조회 2,724
14년 전 조회 2,129
14년 전 조회 2,212
14년 전 조회 2,494
14년 전 조회 1,637
14년 전 조회 4,705
14년 전 조회 1,887
14년 전 조회 2,795
14년 전 조회 2,222
14년 전 조회 1,695
14년 전 조회 5,667
14년 전 조회 1,548
14년 전 조회 3,673
14년 전 조회 1,918
14년 전 조회 1,666
14년 전 조회 2,072
14년 전 조회 8,781
14년 전 조회 1,994
14년 전 조회 3,038
14년 전 조회 2,476
14년 전 조회 2,041
14년 전 조회 5,116
14년 전 조회 1,733