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년 전 조회 742
13년 전 조회 3,073
13년 전 조회 784
13년 전 조회 981
13년 전 조회 765
13년 전 조회 1,145
13년 전 조회 1,093
13년 전 조회 1,351
13년 전 조회 868
13년 전 조회 1,943
13년 전 조회 1,580
13년 전 조회 1,169
13년 전 조회 6,850
13년 전 조회 761
13년 전 조회 1,129
13년 전 조회 955
13년 전 조회 1,127
13년 전 조회 1,399
13년 전 조회 993
13년 전 조회 1,268
13년 전 조회 841
13년 전 조회 861
13년 전 조회 1,386
13년 전 조회 3,263
13년 전 조회 814
13년 전 조회 2,252
13년 전 조회 1,020
13년 전 조회 920
13년 전 조회 1,818
13년 전 조회 1,745
13년 전 조회 754
13년 전 조회 1,661
13년 전 조회 2,083
13년 전 조회 1,497
13년 전 조회 747
13년 전 조회 2,162
13년 전 조회 968
13년 전 조회 749
13년 전 조회 701
13년 전 조회 1,434
13년 전 조회 1,819
13년 전 조회 1,279
13년 전 조회 771
13년 전 조회 911
13년 전 조회 1,398
13년 전 조회 1,352
13년 전 조회 699
13년 전 조회 3,491
13년 전 조회 1,351
13년 전 조회 4,521
13년 전 조회 923
13년 전 조회 1,925
13년 전 조회 986
13년 전 조회 899
13년 전 조회 1,800
13년 전 조회 782
13년 전 조회 1,736
13년 전 조회 844
13년 전 조회 1,615
13년 전 조회 1,142
13년 전 조회 4,198
13년 전 조회 2,199
13년 전 조회 1,019
13년 전 조회 846
13년 전 조회 1,418
13년 전 조회 1,040
13년 전 조회 1,168
13년 전 조회 2,269
13년 전 조회 920
13년 전 조회 2,973
13년 전 조회 2,950
13년 전 조회 1,235
13년 전 조회 934
13년 전 조회 2,454
13년 전 조회 1,048
13년 전 조회 1,306
13년 전 조회 821
13년 전 조회 1,948
13년 전 조회 1,256
13년 전 조회 1,314
13년 전 조회 1,636
13년 전 조회 748
13년 전 조회 3,819
13년 전 조회 1,068
13년 전 조회 1,946
13년 전 조회 1,427
13년 전 조회 810
13년 전 조회 4,793
13년 전 조회 673
13년 전 조회 2,787
13년 전 조회 1,135
13년 전 조회 795
13년 전 조회 1,171
14년 전 조회 7,943
14년 전 조회 1,107
14년 전 조회 2,198
14년 전 조회 1,640
14년 전 조회 1,196
14년 전 조회 4,253
14년 전 조회 851