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년 전 조회 649
13년 전 조회 2,969
13년 전 조회 680
13년 전 조회 874
13년 전 조회 671
13년 전 조회 1,049
13년 전 조회 992
13년 전 조회 1,245
13년 전 조회 772
13년 전 조회 1,840
13년 전 조회 1,473
13년 전 조회 1,060
13년 전 조회 6,742
13년 전 조회 661
13년 전 조회 1,031
13년 전 조회 864
13년 전 조회 1,015
13년 전 조회 1,302
13년 전 조회 895
13년 전 조회 1,151
13년 전 조회 740
13년 전 조회 764
13년 전 조회 1,283
13년 전 조회 3,147
13년 전 조회 716
13년 전 조회 2,143
13년 전 조회 923
13년 전 조회 820
13년 전 조회 1,713
13년 전 조회 1,639
13년 전 조회 649
13년 전 조회 1,561
13년 전 조회 1,985
13년 전 조회 1,387
13년 전 조회 640
13년 전 조회 2,052
13년 전 조회 853
13년 전 조회 641
13년 전 조회 601
13년 전 조회 1,323
13년 전 조회 1,706
13년 전 조회 1,181
13년 전 조회 669
13년 전 조회 803
13년 전 조회 1,299
13년 전 조회 1,250
13년 전 조회 585
13년 전 조회 3,385
13년 전 조회 1,248
13년 전 조회 4,411
13년 전 조회 820
13년 전 조회 1,802
13년 전 조회 886
13년 전 조회 786
13년 전 조회 1,693
13년 전 조회 669
13년 전 조회 1,630
13년 전 조회 734
13년 전 조회 1,509
13년 전 조회 1,032
13년 전 조회 4,084
13년 전 조회 2,085
13년 전 조회 909
13년 전 조회 723
13년 전 조회 1,297
13년 전 조회 929
13년 전 조회 1,063
13년 전 조회 2,155
13년 전 조회 802
13년 전 조회 2,862
13년 전 조회 2,854
13년 전 조회 1,110
13년 전 조회 812
13년 전 조회 2,349
13년 전 조회 941
13년 전 조회 1,185
13년 전 조회 721
13년 전 조회 1,845
13년 전 조회 1,133
13년 전 조회 1,193
13년 전 조회 1,538
13년 전 조회 638
13년 전 조회 3,708
13년 전 조회 957
13년 전 조회 1,833
13년 전 조회 1,333
13년 전 조회 708
13년 전 조회 4,688
13년 전 조회 560
13년 전 조회 2,674
13년 전 조회 1,016
13년 전 조회 691
13년 전 조회 1,060
13년 전 조회 7,827
13년 전 조회 1,008
13년 전 조회 2,099
13년 전 조회 1,543
13년 전 조회 1,076
13년 전 조회 4,133
13년 전 조회 743
🐛 버그신고