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,290
14년 전 조회 3,579
14년 전 조회 1,297
14년 전 조회 1,507
14년 전 조회 1,268
14년 전 조회 1,664
14년 전 조회 1,602
14년 전 조회 1,893
14년 전 조회 1,370
14년 전 조회 2,446
14년 전 조회 2,119
14년 전 조회 1,688
14년 전 조회 7,380
14년 전 조회 1,286
14년 전 조회 1,663
14년 전 조회 1,417
14년 전 조회 1,608
14년 전 조회 1,946
14년 전 조회 1,461
14년 전 조회 1,785
14년 전 조회 1,387
14년 전 조회 1,377
14년 전 조회 1,923
14년 전 조회 3,810
14년 전 조회 1,360
14년 전 조회 2,796
14년 전 조회 1,544
14년 전 조회 1,456
14년 전 조회 2,355
14년 전 조회 2,276
14년 전 조회 1,232
14년 전 조회 2,175
14년 전 조회 2,611
14년 전 조회 2,073
14년 전 조회 1,258
14년 전 조회 2,634
14년 전 조회 1,460
14년 전 조회 1,241
14년 전 조회 1,170
14년 전 조회 1,935
14년 전 조회 2,292
14년 전 조회 1,802
14년 전 조회 1,245
14년 전 조회 1,466
14년 전 조회 1,947
14년 전 조회 1,983
14년 전 조회 1,237
14년 전 조회 4,014
14년 전 조회 1,915
14년 전 조회 5,128
14년 전 조회 1,454
14년 전 조회 2,454
14년 전 조회 1,507
14년 전 조회 1,430
14년 전 조회 2,298
14년 전 조회 1,321
14년 전 조회 2,285
14년 전 조회 1,392
14년 전 조회 2,125
14년 전 조회 1,673
14년 전 조회 4,693
14년 전 조회 2,682
14년 전 조회 1,536
14년 전 조회 1,388
14년 전 조회 1,945
14년 전 조회 1,593
14년 전 조회 1,686
14년 전 조회 2,788
14년 전 조회 1,395
14년 전 조회 3,541
14년 전 조회 3,485
14년 전 조회 1,800
14년 전 조회 1,474
14년 전 조회 2,956
14년 전 조회 1,587
14년 전 조회 1,853
14년 전 조회 1,304
14년 전 조회 2,433
14년 전 조회 1,804
14년 전 조회 1,859
14년 전 조회 2,156
14년 전 조회 1,290
14년 전 조회 4,347
14년 전 조회 1,560
14년 전 조회 2,450
14년 전 조회 1,925
14년 전 조회 1,359
14년 전 조회 5,341
14년 전 조회 1,196
14년 전 조회 3,305
14년 전 조회 1,635
14년 전 조회 1,328
14년 전 조회 1,718
14년 전 조회 8,477
14년 전 조회 1,652
14년 전 조회 2,697
14년 전 조회 2,164
14년 전 조회 1,726
14년 전 조회 4,776
14년 전 조회 1,405