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년 전 조회 680
13년 전 조회 3,008
13년 전 조회 719
13년 전 조회 913
13년 전 조회 703
13년 전 조회 1,084
13년 전 조회 1,026
13년 전 조회 1,285
13년 전 조회 812
13년 전 조회 1,876
13년 전 조회 1,510
13년 전 조회 1,097
13년 전 조회 6,782
13년 전 조회 694
13년 전 조회 1,059
13년 전 조회 903
13년 전 조회 1,052
13년 전 조회 1,333
13년 전 조회 932
13년 전 조회 1,193
13년 전 조회 775
13년 전 조회 797
13년 전 조회 1,320
13년 전 조회 3,185
13년 전 조회 747
13년 전 조회 2,182
13년 전 조회 960
13년 전 조회 862
13년 전 조회 1,751
13년 전 조회 1,682
13년 전 조회 690
13년 전 조회 1,595
13년 전 조회 2,023
13년 전 조회 1,431
13년 전 조회 675
13년 전 조회 2,095
13년 전 조회 897
13년 전 조회 673
13년 전 조회 642
13년 전 조회 1,364
13년 전 조회 1,743
13년 전 조회 1,218
13년 전 조회 708
13년 전 조회 845
13년 전 조회 1,333
13년 전 조회 1,288
13년 전 조회 621
13년 전 조회 3,420
13년 전 조회 1,282
13년 전 조회 4,448
13년 전 조회 851
13년 전 조회 1,846
13년 전 조회 929
13년 전 조회 823
13년 전 조회 1,730
13년 전 조회 702
13년 전 조회 1,671
13년 전 조회 760
13년 전 조회 1,548
13년 전 조회 1,069
13년 전 조회 4,132
13년 전 조회 2,129
13년 전 조회 948
13년 전 조회 773
13년 전 조회 1,335
13년 전 조회 980
13년 전 조회 1,102
13년 전 조회 2,197
13년 전 조회 848
13년 전 조회 2,904
13년 전 조회 2,899
13년 전 조회 1,155
13년 전 조회 855
13년 전 조회 2,389
13년 전 조회 979
13년 전 조회 1,235
13년 전 조회 759
13년 전 조회 1,880
13년 전 조회 1,179
13년 전 조회 1,236
13년 전 조회 1,578
13년 전 조회 677
13년 전 조회 3,751
13년 전 조회 1,001
13년 전 조회 1,877
13년 전 조회 1,375
13년 전 조회 745
13년 전 조회 4,727
13년 전 조회 595
13년 전 조회 2,716
13년 전 조회 1,055
13년 전 조회 724
13년 전 조회 1,100
13년 전 조회 7,870
13년 전 조회 1,042
13년 전 조회 2,131
13년 전 조회 1,573
13년 전 조회 1,117
13년 전 조회 4,171
13년 전 조회 786
🐛 버그신고