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년 전 조회 647
13년 전 조회 2,969
13년 전 조회 679
13년 전 조회 874
13년 전 조회 669
13년 전 조회 1,047
13년 전 조회 990
13년 전 조회 1,244
13년 전 조회 772
13년 전 조회 1,837
13년 전 조회 1,472
13년 전 조회 1,059
13년 전 조회 6,738
13년 전 조회 661
13년 전 조회 1,028
13년 전 조회 864
13년 전 조회 1,015
13년 전 조회 1,301
13년 전 조회 894
13년 전 조회 1,149
13년 전 조회 740
13년 전 조회 763
13년 전 조회 1,282
13년 전 조회 3,147
13년 전 조회 716
13년 전 조회 2,143
13년 전 조회 923
13년 전 조회 819
13년 전 조회 1,712
13년 전 조회 1,639
13년 전 조회 648
13년 전 조회 1,558
13년 전 조회 1,983
13년 전 조회 1,386
13년 전 조회 636
13년 전 조회 2,050
13년 전 조회 851
13년 전 조회 640
13년 전 조회 598
13년 전 조회 1,321
13년 전 조회 1,703
13년 전 조회 1,179
13년 전 조회 669
13년 전 조회 802
13년 전 조회 1,298
13년 전 조회 1,246
13년 전 조회 584
13년 전 조회 3,385
13년 전 조회 1,248
13년 전 조회 4,410
13년 전 조회 817
13년 전 조회 1,801
13년 전 조회 884
13년 전 조회 783
13년 전 조회 1,691
13년 전 조회 665
13년 전 조회 1,630
13년 전 조회 730
13년 전 조회 1,507
13년 전 조회 1,031
13년 전 조회 4,082
13년 전 조회 2,082
13년 전 조회 908
13년 전 조회 723
13년 전 조회 1,294
13년 전 조회 927
13년 전 조회 1,062
13년 전 조회 2,155
13년 전 조회 802
13년 전 조회 2,860
13년 전 조회 2,852
13년 전 조회 1,110
13년 전 조회 810
13년 전 조회 2,348
13년 전 조회 938
13년 전 조회 1,185
13년 전 조회 720
13년 전 조회 1,842
13년 전 조회 1,133
13년 전 조회 1,192
13년 전 조회 1,536
13년 전 조회 636
13년 전 조회 3,705
13년 전 조회 956
13년 전 조회 1,833
13년 전 조회 1,328
13년 전 조회 706
13년 전 조회 4,688
13년 전 조회 560
13년 전 조회 2,672
13년 전 조회 1,014
13년 전 조회 690
13년 전 조회 1,059
13년 전 조회 7,825
13년 전 조회 1,006
13년 전 조회 2,098
13년 전 조회 1,542
13년 전 조회 1,074
13년 전 조회 4,131
13년 전 조회 741
🐛 버그신고