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년 전 조회 684
13년 전 조회 3,014
13년 전 조회 725
13년 전 조회 923
13년 전 조회 716
13년 전 조회 1,092
13년 전 조회 1,032
13년 전 조회 1,293
13년 전 조회 819
13년 전 조회 1,880
13년 전 조회 1,515
13년 전 조회 1,102
13년 전 조회 6,789
13년 전 조회 700
13년 전 조회 1,068
13년 전 조회 906
13년 전 조회 1,062
13년 전 조회 1,342
13년 전 조회 937
13년 전 조회 1,202
13년 전 조회 781
13년 전 조회 801
13년 전 조회 1,328
13년 전 조회 3,201
13년 전 조회 754
13년 전 조회 2,190
13년 전 조회 964
13년 전 조회 865
13년 전 조회 1,759
13년 전 조회 1,688
13년 전 조회 696
13년 전 조회 1,602
13년 전 조회 2,029
13년 전 조회 1,441
13년 전 조회 686
13년 전 조회 2,101
13년 전 조회 902
13년 전 조회 682
13년 전 조회 648
13년 전 조회 1,374
13년 전 조회 1,753
13년 전 조회 1,227
13년 전 조회 715
13년 전 조회 850
13년 전 조회 1,337
13년 전 조회 1,291
13년 전 조회 628
13년 전 조회 3,424
13년 전 조회 1,294
13년 전 조회 4,453
13년 전 조회 856
13년 전 조회 1,852
13년 전 조회 937
13년 전 조회 836
13년 전 조회 1,739
13년 전 조회 710
13년 전 조회 1,680
13년 전 조회 767
13년 전 조회 1,550
13년 전 조회 1,078
13년 전 조회 4,138
13년 전 조회 2,137
13년 전 조회 955
13년 전 조회 782
13년 전 조회 1,342
13년 전 조회 982
13년 전 조회 1,110
13년 전 조회 2,201
13년 전 조회 854
13년 전 조회 2,913
13년 전 조회 2,901
13년 전 조회 1,156
13년 전 조회 861
13년 전 조회 2,396
13년 전 조회 987
13년 전 조회 1,241
13년 전 조회 764
13년 전 조회 1,888
13년 전 조회 1,189
13년 전 조회 1,244
13년 전 조회 1,580
13년 전 조회 682
13년 전 조회 3,755
13년 전 조회 1,010
13년 전 조회 1,887
13년 전 조회 1,382
13년 전 조회 755
13년 전 조회 4,731
13년 전 조회 600
13년 전 조회 2,724
13년 전 조회 1,063
13년 전 조회 730
13년 전 조회 1,105
13년 전 조회 7,876
13년 전 조회 1,048
13년 전 조회 2,136
13년 전 조회 1,583
13년 전 조회 1,124
13년 전 조회 4,177
13년 전 조회 790
🐛 버그신고