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년 전 조회 609
13년 전 조회 2,940
13년 전 조회 645
13년 전 조회 836
13년 전 조회 632
13년 전 조회 1,008
13년 전 조회 950
13년 전 조회 1,215
13년 전 조회 737
13년 전 조회 1,806
13년 전 조회 1,445
13년 전 조회 1,034
13년 전 조회 6,713
13년 전 조회 631
13년 전 조회 1,003
13년 전 조회 842
13년 전 조회 984
13년 전 조회 1,268
13년 전 조회 861
13년 전 조회 1,121
13년 전 조회 711
13년 전 조회 732
13년 전 조회 1,258
13년 전 조회 3,119
13년 전 조회 688
13년 전 조회 2,112
13년 전 조회 891
13년 전 조회 794
13년 전 조회 1,685
13년 전 조회 1,609
13년 전 조회 624
13년 전 조회 1,529
13년 전 조회 1,958
13년 전 조회 1,355
13년 전 조회 615
13년 전 조회 2,025
13년 전 조회 826
13년 전 조회 606
13년 전 조회 576
13년 전 조회 1,299
13년 전 조회 1,680
13년 전 조회 1,148
13년 전 조회 636
13년 전 조회 777
13년 전 조회 1,270
13년 전 조회 1,224
13년 전 조회 557
13년 전 조회 3,360
13년 전 조회 1,221
13년 전 조회 4,390
13년 전 조회 790
13년 전 조회 1,777
13년 전 조회 845
13년 전 조회 759
13년 전 조회 1,661
13년 전 조회 637
13년 전 조회 1,600
13년 전 조회 700
13년 전 조회 1,484
13년 전 조회 1,009
13년 전 조회 4,062
13년 전 조회 2,056
13년 전 조회 884
13년 전 조회 702
13년 전 조회 1,278
13년 전 조회 903
13년 전 조회 1,037
13년 전 조회 2,131
13년 전 조회 780
13년 전 조회 2,835
13년 전 조회 2,826
13년 전 조회 1,094
13년 전 조회 793
13년 전 조회 2,333
13년 전 조회 909
13년 전 조회 1,168
13년 전 조회 698
13년 전 조회 1,821
13년 전 조회 1,116
13년 전 조회 1,170
13년 전 조회 1,517
13년 전 조회 617
13년 전 조회 3,684
13년 전 조회 927
13년 전 조회 1,807
13년 전 조회 1,303
13년 전 조회 681
13년 전 조회 4,662
13년 전 조회 536
13년 전 조회 2,651
13년 전 조회 1,000
13년 전 조회 669
13년 전 조회 1,039
13년 전 조회 7,803
13년 전 조회 985
13년 전 조회 2,074
13년 전 조회 1,518
13년 전 조회 1,050
13년 전 조회 4,112
13년 전 조회 717
🐛 버그신고