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개

일단 츄쳔해써욤
감사합니다.
추천합니다..
추천합니다.
감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,243
14년 전 조회 3,563
14년 전 조회 1,276
14년 전 조회 1,465
14년 전 조회 1,221
14년 전 조회 1,621
14년 전 조회 1,551
14년 전 조회 1,843
14년 전 조회 1,319
14년 전 조회 2,438
14년 전 조회 2,067
14년 전 조회 1,634
14년 전 조회 7,324
14년 전 조회 1,235
14년 전 조회 1,610
14년 전 조회 1,373
14년 전 조회 1,593
14년 전 조회 1,899
14년 전 조회 1,443
14년 전 조회 1,735
14년 전 조회 1,348
14년 전 조회 1,365
14년 전 조회 1,878
14년 전 조회 3,756
14년 전 조회 1,302
14년 전 조회 2,742
14년 전 조회 1,499
14년 전 조회 1,409
14년 전 조회 2,304
14년 전 조회 2,221
14년 전 조회 1,190
14년 전 조회 2,123
14년 전 조회 2,564
14년 전 조회 2,042
14년 전 조회 1,197
14년 전 조회 2,600
14년 전 조회 1,413
14년 전 조회 1,199
14년 전 조회 1,124
14년 전 조회 1,898
14년 전 조회 2,256
14년 전 조회 1,754
14년 전 조회 1,201
14년 전 조회 1,426
14년 전 조회 1,897
14년 전 조회 1,949
14년 전 조회 1,188
14년 전 조회 3,970
14년 전 조회 1,864
14년 전 조회 5,098
14년 전 조회 1,414
14년 전 조회 2,399
14년 전 조회 1,458
14년 전 조회 1,381
14년 전 조회 2,281
14년 전 조회 1,270
14년 전 조회 2,240
14년 전 조회 1,338
14년 전 조회 2,110
14년 전 조회 1,633
14년 전 조회 4,673
14년 전 조회 2,669
14년 전 조회 1,522
14년 전 조회 1,345
14년 전 조회 1,926
14년 전 조회 1,552
14년 전 조회 1,673
14년 전 조회 2,739
14년 전 조회 1,377
14년 전 조회 3,483
14년 전 조회 3,466
14년 전 조회 1,748
14년 전 조회 1,435
14년 전 조회 2,930
14년 전 조회 1,539
14년 전 조회 1,810
14년 전 조회 1,291
14년 전 조회 2,410
14년 전 조회 1,750
14년 전 조회 1,819
14년 전 조회 2,095
14년 전 조회 1,243
14년 전 조회 4,305
14년 전 조회 1,550
14년 전 조회 2,403
14년 전 조회 1,911
14년 전 조회 1,305
14년 전 조회 5,295
14년 전 조회 1,149
14년 전 조회 3,254
14년 전 조회 1,621
14년 전 조회 1,286
14년 전 조회 1,679
14년 전 조회 8,426
14년 전 조회 1,595
14년 전 조회 2,646
14년 전 조회 2,115
14년 전 조회 1,687
14년 전 조회 4,734
14년 전 조회 1,350