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년 전 조회 694
13년 전 조회 3,023
13년 전 조회 731
13년 전 조회 938
13년 전 조회 727
13년 전 조회 1,100
13년 전 조회 1,042
13년 전 조회 1,302
13년 전 조회 827
13년 전 조회 1,891
13년 전 조회 1,524
13년 전 조회 1,120
13년 전 조회 6,805
13년 전 조회 718
13년 전 조회 1,084
13년 전 조회 911
13년 전 조회 1,077
13년 전 조회 1,353
13년 전 조회 952
13년 전 조회 1,212
13년 전 조회 789
13년 전 조회 813
13년 전 조회 1,342
13년 전 조회 3,220
13년 전 조회 767
13년 전 조회 2,202
13년 전 조회 981
13년 전 조회 875
13년 전 조회 1,772
13년 전 조회 1,704
13년 전 조회 707
13년 전 조회 1,618
13년 전 조회 2,040
13년 전 조회 1,454
13년 전 조회 705
13년 전 조회 2,113
13년 전 조회 919
13년 전 조회 698
13년 전 조회 658
13년 전 조회 1,382
13년 전 조회 1,774
13년 전 조회 1,239
13년 전 조회 728
13년 전 조회 864
13년 전 조회 1,346
13년 전 조회 1,303
13년 전 조회 646
13년 전 조회 3,435
13년 전 조회 1,301
13년 전 조회 4,467
13년 전 조회 871
13년 전 조회 1,865
13년 전 조회 947
13년 전 조회 852
13년 전 조회 1,757
13년 전 조회 719
13년 전 조회 1,692
13년 전 조회 780
13년 전 조회 1,562
13년 전 조회 1,095
13년 전 조회 4,152
13년 전 조회 2,150
13년 전 조회 969
13년 전 조회 800
13년 전 조회 1,359
13년 전 조회 992
13년 전 조회 1,123
13년 전 조회 2,211
13년 전 조회 870
13년 전 조회 2,924
13년 전 조회 2,917
13년 전 조회 1,174
13년 전 조회 880
13년 전 조회 2,403
13년 전 조회 1,005
13년 전 조회 1,258
13년 전 조회 779
13년 전 조회 1,906
13년 전 조회 1,204
13년 전 조회 1,259
13년 전 조회 1,589
13년 전 조회 695
13년 전 조회 3,769
13년 전 조회 1,027
13년 전 조회 1,899
13년 전 조회 1,393
13년 전 조회 769
13년 전 조회 4,744
13년 전 조회 617
13년 전 조회 2,738
13년 전 조회 1,077
13년 전 조회 747
13년 전 조회 1,120
13년 전 조회 7,892
13년 전 조회 1,056
13년 전 조회 2,146
13년 전 조회 1,594
13년 전 조회 1,138
13년 전 조회 4,195
13년 전 조회 810
🐛 버그신고