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,270
14년 전 조회 3,577
14년 전 조회 1,289
14년 전 조회 1,482
14년 전 조회 1,247
14년 전 조회 1,642
14년 전 조회 1,581
14년 전 조회 1,869
14년 전 조회 1,345
14년 전 조회 2,444
14년 전 조회 2,092
14년 전 조회 1,664
14년 전 조회 7,346
14년 전 조회 1,257
14년 전 조회 1,638
14년 전 조회 1,394
14년 전 조회 1,604
14년 전 조회 1,923
14년 전 조회 1,454
14년 전 조회 1,756
14년 전 조회 1,365
14년 전 조회 1,373
14년 전 조회 1,902
14년 전 조회 3,786
14년 전 조회 1,331
14년 전 조회 2,767
14년 전 조회 1,524
14년 전 조회 1,433
14년 전 조회 2,331
14년 전 조회 2,247
14년 전 조회 1,212
14년 전 조회 2,154
14년 전 조회 2,586
14년 전 조회 2,059
14년 전 조회 1,229
14년 전 조회 2,616
14년 전 조회 1,435
14년 전 조회 1,219
14년 전 조회 1,145
14년 전 조회 1,916
14년 전 조회 2,277
14년 전 조회 1,780
14년 전 조회 1,231
14년 전 조회 1,446
14년 전 조회 1,921
14년 전 조회 1,971
14년 전 조회 1,214
14년 전 조회 3,993
14년 전 조회 1,892
14년 전 조회 5,115
14년 전 조회 1,435
14년 전 조회 2,427
14년 전 조회 1,488
14년 전 조회 1,410
14년 전 조회 2,292
14년 전 조회 1,296
14년 전 조회 2,265
14년 전 조회 1,368
14년 전 조회 2,121
14년 전 조회 1,656
14년 전 조회 4,689
14년 전 조회 2,678
14년 전 조회 1,530
14년 전 조회 1,367
14년 전 조회 1,942
14년 전 조회 1,569
14년 전 조회 1,682
14년 전 조회 2,764
14년 전 조회 1,388
14년 전 조회 3,513
14년 전 조회 3,480
14년 전 조회 1,776
14년 전 조회 1,451
14년 전 조회 2,948
14년 전 조회 1,561
14년 전 조회 1,834
14년 전 조회 1,303
14년 전 조회 2,427
14년 전 조회 1,782
14년 전 조회 1,836
14년 전 조회 2,128
14년 전 조회 1,267
14년 전 조회 4,322
14년 전 조회 1,557
14년 전 조회 2,431
14년 전 조회 1,917
14년 전 조회 1,331
14년 전 조회 5,323
14년 전 조회 1,168
14년 전 조회 3,283
14년 전 조회 1,633
14년 전 조회 1,305
14년 전 조회 1,697
14년 전 조회 8,453
14년 전 조회 1,632
14년 전 조회 2,672
14년 전 조회 2,147
14년 전 조회 1,708
14년 전 조회 4,756
14년 전 조회 1,376