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개

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

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 732
13년 전 조회 3,065
13년 전 조회 774
13년 전 조회 976
13년 전 조회 757
13년 전 조회 1,141
13년 전 조회 1,085
13년 전 조회 1,342
13년 전 조회 860
13년 전 조회 1,933
13년 전 조회 1,574
13년 전 조회 1,157
13년 전 조회 6,843
13년 전 조회 753
13년 전 조회 1,124
13년 전 조회 951
13년 전 조회 1,114
13년 전 조회 1,393
13년 전 조회 984
13년 전 조회 1,258
13년 전 조회 834
13년 전 조회 854
13년 전 조회 1,382
13년 전 조회 3,259
13년 전 조회 802
13년 전 조회 2,247
13년 전 조회 1,015
13년 전 조회 912
13년 전 조회 1,807
13년 전 조회 1,738
13년 전 조회 744
13년 전 조회 1,657
13년 전 조회 2,076
13년 전 조회 1,491
13년 전 조회 740
13년 전 조회 2,156
13년 전 조회 960
13년 전 조회 741
13년 전 조회 694
13년 전 조회 1,428
13년 전 조회 1,812
13년 전 조회 1,277
13년 전 조회 761
13년 전 조회 905
13년 전 조회 1,392
13년 전 조회 1,346
13년 전 조회 685
13년 전 조회 3,488
13년 전 조회 1,344
13년 전 조회 4,515
13년 전 조회 915
13년 전 조회 1,916
13년 전 조회 978
13년 전 조회 891
13년 전 조회 1,795
13년 전 조회 776
13년 전 조회 1,726
13년 전 조회 836
13년 전 조회 1,604
13년 전 조회 1,135
13년 전 조회 4,193
13년 전 조회 2,192
13년 전 조회 1,013
13년 전 조회 842
13년 전 조회 1,408
13년 전 조회 1,030
13년 전 조회 1,160
13년 전 조회 2,264
13년 전 조회 915
13년 전 조회 2,964
13년 전 조회 2,946
13년 전 조회 1,229
13년 전 조회 929
13년 전 조회 2,447
13년 전 조회 1,041
13년 전 조회 1,299
13년 전 조회 816
13년 전 조회 1,938
13년 전 조회 1,250
13년 전 조회 1,308
13년 전 조회 1,628
13년 전 조회 742
13년 전 조회 3,809
13년 전 조회 1,063
13년 전 조회 1,940
13년 전 조회 1,418
13년 전 조회 805
13년 전 조회 4,784
13년 전 조회 666
13년 전 조회 2,780
13년 전 조회 1,124
13년 전 조회 787
13년 전 조회 1,166
13년 전 조회 7,937
13년 전 조회 1,099
13년 전 조회 2,192
14년 전 조회 1,635
14년 전 조회 1,187
14년 전 조회 4,247
14년 전 조회 844