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,351
14년 전 조회 3,612
14년 전 조회 1,330
14년 전 조회 1,586
14년 전 조회 1,336
14년 전 조회 1,753
14년 전 조회 1,666
14년 전 조회 1,961
14년 전 조회 1,439
14년 전 조회 2,482
14년 전 조회 2,180
14년 전 조회 1,754
14년 전 조회 7,441
14년 전 조회 1,348
14년 전 조회 1,721
14년 전 조회 1,491
14년 전 조회 1,647
14년 전 조회 2,016
14년 전 조회 1,493
14년 전 조회 1,857
14년 전 조회 1,451
14년 전 조회 1,413
14년 전 조회 2,010
14년 전 조회 3,885
14년 전 조회 1,408
14년 전 조회 2,854
14년 전 조회 1,609
14년 전 조회 1,520
14년 전 조회 2,429
14년 전 조회 2,336
14년 전 조회 1,296
14년 전 조회 2,240
14년 전 조회 2,663
14년 전 조회 2,112
14년 전 조회 1,323
14년 전 조회 2,700
14년 전 조회 1,516
14년 전 조회 1,294
14년 전 조회 1,233
14년 전 조회 2,005
14년 전 조회 2,352
14년 전 조회 1,863
14년 전 조회 1,313
14년 전 조회 1,553
14년 전 조회 2,021
14년 전 조회 2,019
14년 전 조회 1,305
14년 전 조회 4,082
14년 전 조회 1,980
14년 전 조회 5,175
14년 전 조회 1,522
14년 전 조회 2,536
14년 전 조회 1,562
14년 전 조회 1,498
14년 전 조회 2,324
14년 전 조회 1,395
14년 전 조회 2,350
14년 전 조회 1,448
14년 전 조회 2,161
14년 전 조회 1,742
14년 전 조회 4,721
14년 전 조회 2,716
14년 전 조회 1,568
14년 전 조회 1,447
14년 전 조회 1,978
14년 전 조회 1,653
14년 전 조회 1,724
14년 전 조회 2,857
14년 전 조회 1,428
14년 전 조회 3,611
14년 전 조회 3,510
14년 전 조회 1,861
14년 전 조회 1,537
14년 전 조회 2,985
14년 전 조회 1,660
14년 전 조회 1,915
14년 전 조회 1,345
14년 전 조회 2,473
14년 전 조회 1,869
14년 전 조회 1,932
14년 전 조회 2,230
14년 전 조회 1,352
14년 전 조회 4,423
14년 전 조회 1,593
14년 전 조회 2,501
14년 전 조회 1,962
14년 전 조회 1,418
14년 전 조회 5,400
14년 전 조회 1,262
14년 전 조회 3,372
14년 전 조회 1,661
14년 전 조회 1,407
14년 전 조회 1,790
14년 전 조회 8,549
14년 전 조회 1,715
14년 전 조회 2,765
14년 전 조회 2,230
14년 전 조회 1,792
14년 전 조회 4,850
14년 전 조회 1,470