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년 전 조회 708
13년 전 조회 3,043
13년 전 조회 757
13년 전 조회 957
13년 전 조회 740
13년 전 조회 1,121
13년 전 조회 1,064
13년 전 조회 1,321
13년 전 조회 848
13년 전 조회 1,908
13년 전 조회 1,550
13년 전 조회 1,136
13년 전 조회 6,826
13년 전 조회 734
13년 전 조회 1,100
13년 전 조회 933
13년 전 조회 1,094
13년 전 조회 1,376
13년 전 조회 965
13년 전 조회 1,234
13년 전 조회 809
13년 전 조회 836
13년 전 조회 1,364
13년 전 조회 3,238
13년 전 조회 787
13년 전 조회 2,229
13년 전 조회 997
13년 전 조회 898
13년 전 조회 1,788
13년 전 조회 1,717
13년 전 조회 726
13년 전 조회 1,637
13년 전 조회 2,061
13년 전 조회 1,469
13년 전 조회 721
13년 전 조회 2,137
13년 전 조회 940
13년 전 조회 718
13년 전 조회 675
13년 전 조회 1,401
13년 전 조회 1,797
13년 전 조회 1,259
13년 전 조회 742
13년 전 조회 882
13년 전 조회 1,375
13년 전 조회 1,329
13년 전 조회 667
13년 전 조회 3,460
13년 전 조회 1,328
13년 전 조회 4,484
13년 전 조회 897
13년 전 조회 1,890
13년 전 조회 961
13년 전 조회 872
13년 전 조회 1,778
13년 전 조회 746
13년 전 조회 1,712
13년 전 조회 808
13년 전 조회 1,576
13년 전 조회 1,112
13년 전 조회 4,169
13년 전 조회 2,166
13년 전 조회 994
13년 전 조회 816
13년 전 조회 1,385
13년 전 조회 1,011
13년 전 조회 1,141
13년 전 조회 2,236
13년 전 조회 897
13년 전 조회 2,943
13년 전 조회 2,933
13년 전 조회 1,207
13년 전 조회 905
13년 전 조회 2,424
13년 전 조회 1,019
13년 전 조회 1,274
13년 전 조회 800
13년 전 조회 1,919
13년 전 조회 1,227
13년 전 조회 1,283
13년 전 조회 1,609
13년 전 조회 718
13년 전 조회 3,793
13년 전 조회 1,044
13년 전 조회 1,917
13년 전 조회 1,407
13년 전 조회 787
13년 전 조회 4,764
13년 전 조회 645
13년 전 조회 2,761
13년 전 조회 1,104
13년 전 조회 765
13년 전 조회 1,142
13년 전 조회 7,912
13년 전 조회 1,080
13년 전 조회 2,169
13년 전 조회 1,610
13년 전 조회 1,156
13년 전 조회 4,224
13년 전 조회 825