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년 전 조회 673
13년 전 조회 2,998
13년 전 조회 708
13년 전 조회 908
13년 전 조회 693
13년 전 조회 1,076
13년 전 조회 1,016
13년 전 조회 1,280
13년 전 조회 800
13년 전 조회 1,869
13년 전 조회 1,498
13년 전 조회 1,087
13년 전 조회 6,769
13년 전 조회 684
13년 전 조회 1,051
13년 전 조회 894
13년 전 조회 1,043
13년 전 조회 1,329
13년 전 조회 919
13년 전 조회 1,187
13년 전 조회 764
13년 전 조회 792
13년 전 조회 1,313
13년 전 조회 3,176
13년 전 조회 740
13년 전 조회 2,172
13년 전 조회 947
13년 전 조회 848
13년 전 조회 1,744
13년 전 조회 1,671
13년 전 조회 680
13년 전 조회 1,587
13년 전 조회 2,009
13년 전 조회 1,420
13년 전 조회 670
13년 전 조회 2,084
13년 전 조회 885
13년 전 조회 665
13년 전 조회 636
13년 전 조회 1,357
13년 전 조회 1,732
13년 전 조회 1,208
13년 전 조회 701
13년 전 조회 835
13년 전 조회 1,323
13년 전 조회 1,280
13년 전 조회 613
13년 전 조회 3,414
13년 전 조회 1,269
13년 전 조회 4,439
13년 전 조회 844
13년 전 조회 1,835
13년 전 조회 922
13년 전 조회 816
13년 전 조회 1,723
13년 전 조회 694
13년 전 조회 1,665
13년 전 조회 751
13년 전 조회 1,536
13년 전 조회 1,062
13년 전 조회 4,120
13년 전 조회 2,114
13년 전 조회 937
13년 전 조회 765
13년 전 조회 1,321
13년 전 조회 966
13년 전 조회 1,096
13년 전 조회 2,189
13년 전 조회 839
13년 전 조회 2,900
13년 전 조회 2,884
13년 전 조회 1,143
13년 전 조회 841
13년 전 조회 2,380
13년 전 조회 970
13년 전 조회 1,223
13년 전 조회 749
13년 전 조회 1,873
13년 전 조회 1,168
13년 전 조회 1,221
13년 전 조회 1,572
13년 전 조회 662
13년 전 조회 3,739
13년 전 조회 990
13년 전 조회 1,865
13년 전 조회 1,365
13년 전 조회 737
13년 전 조회 4,717
13년 전 조회 584
13년 전 조회 2,708
13년 전 조회 1,044
13년 전 조회 717
13년 전 조회 1,091
13년 전 조회 7,863
13년 전 조회 1,036
13년 전 조회 2,120
13년 전 조회 1,565
13년 전 조회 1,106
13년 전 조회 4,159
13년 전 조회 777
🐛 버그신고