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년 전 조회 626
13년 전 조회 2,955
13년 전 조회 655
13년 전 조회 852
13년 전 조회 647
13년 전 조회 1,029
13년 전 조회 965
13년 전 조회 1,225
13년 전 조회 753
13년 전 조회 1,819
13년 전 조회 1,455
13년 전 조회 1,039
13년 전 조회 6,721
13년 전 조회 645
13년 전 조회 1,014
13년 전 조회 851
13년 전 조회 998
13년 전 조회 1,286
13년 전 조회 880
13년 전 조회 1,130
13년 전 조회 720
13년 전 조회 744
13년 전 조회 1,266
13년 전 조회 3,128
13년 전 조회 701
13년 전 조회 2,128
13년 전 조회 903
13년 전 조회 804
13년 전 조회 1,694
13년 전 조회 1,622
13년 전 조회 638
13년 전 조회 1,541
13년 전 조회 1,974
13년 전 조회 1,369
13년 전 조회 624
13년 전 조회 2,037
13년 전 조회 839
13년 전 조회 623
13년 전 조회 588
13년 전 조회 1,305
13년 전 조회 1,689
13년 전 조회 1,161
13년 전 조회 647
13년 전 조회 791
13년 전 조회 1,284
13년 전 조회 1,231
13년 전 조회 571
13년 전 조회 3,373
13년 전 조회 1,230
13년 전 조회 4,396
13년 전 조회 799
13년 전 조회 1,789
13년 전 조회 858
13년 전 조회 767
13년 전 조회 1,673
13년 전 조회 650
13년 전 조회 1,615
13년 전 조회 714
13년 전 조회 1,494
13년 전 조회 1,017
13년 전 조회 4,071
13년 전 조회 2,066
13년 전 조회 897
13년 전 조회 712
13년 전 조회 1,286
13년 전 조회 914
13년 전 조회 1,044
13년 전 조회 2,141
13년 전 조회 791
13년 전 조회 2,843
13년 전 조회 2,840
13년 전 조회 1,098
13년 전 조회 803
13년 전 조회 2,342
13년 전 조회 925
13년 전 조회 1,175
13년 전 조회 706
13년 전 조회 1,830
13년 전 조회 1,121
13년 전 조회 1,180
13년 전 조회 1,523
13년 전 조회 625
13년 전 조회 3,691
13년 전 조회 941
13년 전 조회 1,817
13년 전 조회 1,313
13년 전 조회 692
13년 전 조회 4,674
13년 전 조회 548
13년 전 조회 2,659
13년 전 조회 1,007
13년 전 조회 678
13년 전 조회 1,047
13년 전 조회 7,815
13년 전 조회 995
13년 전 조회 2,081
13년 전 조회 1,525
13년 전 조회 1,060
13년 전 조회 4,119
13년 전 조회 727
🐛 버그신고