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년 전 조회 1,235
13년 전 조회 3,555
13년 전 조회 1,269
14년 전 조회 1,460
14년 전 조회 1,214
14년 전 조회 1,614
14년 전 조회 1,544
14년 전 조회 1,836
14년 전 조회 1,316
14년 전 조회 2,431
14년 전 조회 2,058
14년 전 조회 1,629
14년 전 조회 7,313
14년 전 조회 1,232
14년 전 조회 1,601
14년 전 조회 1,370
14년 전 조회 1,589
14년 전 조회 1,888
14년 전 조회 1,436
14년 전 조회 1,732
14년 전 조회 1,338
14년 전 조회 1,358
14년 전 조회 1,874
14년 전 조회 3,751
14년 전 조회 1,298
14년 전 조회 2,732
14년 전 조회 1,494
14년 전 조회 1,401
14년 전 조회 2,293
14년 전 조회 2,211
14년 전 조회 1,186
14년 전 조회 2,112
14년 전 조회 2,557
14년 전 조회 2,037
14년 전 조회 1,192
14년 전 조회 2,594
14년 전 조회 1,406
14년 전 조회 1,193
14년 전 조회 1,115
14년 전 조회 1,891
14년 전 조회 2,246
14년 전 조회 1,752
14년 전 조회 1,195
14년 전 조회 1,419
14년 전 조회 1,894
14년 전 조회 1,937
14년 전 조회 1,180
14년 전 조회 3,964
14년 전 조회 1,857
14년 전 조회 5,090
14년 전 조회 1,409
14년 전 조회 2,389
14년 전 조회 1,452
14년 전 조회 1,374
14년 전 조회 2,275
14년 전 조회 1,265
14년 전 조회 2,232
14년 전 조회 1,327
14년 전 조회 2,102
14년 전 조회 1,627
14년 전 조회 4,668
14년 전 조회 2,661
14년 전 조회 1,515
14년 전 조회 1,336
14년 전 조회 1,916
14년 전 조회 1,544
14년 전 조회 1,667
14년 전 조회 2,735
14년 전 조회 1,370
14년 전 조회 3,472
14년 전 조회 3,458
14년 전 조회 1,740
14년 전 조회 1,424
14년 전 조회 2,920
14년 전 조회 1,534
14년 전 조회 1,805
14년 전 조회 1,285
14년 전 조회 2,407
14년 전 조회 1,741
14년 전 조회 1,813
14년 전 조회 2,083
14년 전 조회 1,236
14년 전 조회 4,297
14년 전 조회 1,544
14년 전 조회 2,397
14년 전 조회 1,903
14년 전 조회 1,294
14년 전 조회 5,286
14년 전 조회 1,144
14년 전 조회 3,251
14년 전 조회 1,609
14년 전 조회 1,275
14년 전 조회 1,670
14년 전 조회 8,421
14년 전 조회 1,581
14년 전 조회 2,634
14년 전 조회 2,106
14년 전 조회 1,678
14년 전 조회 4,726
14년 전 조회 1,346