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,512
14년 전 조회 3,803
14년 전 조회 1,495
14년 전 조회 1,730
14년 전 조회 1,472
14년 전 조회 1,898
14년 전 조회 1,807
14년 전 조회 2,112
14년 전 조회 1,577
14년 전 조회 2,644
14년 전 조회 2,332
14년 전 조회 1,887
14년 전 조회 7,576
14년 전 조회 1,506
14년 전 조회 1,862
14년 전 조회 1,627
14년 전 조회 1,810
14년 전 조회 2,142
14년 전 조회 1,657
14년 전 조회 2,013
14년 전 조회 1,588
14년 전 조회 1,578
14년 전 조회 2,158
14년 전 조회 4,025
14년 전 조회 1,563
14년 전 조회 2,995
14년 전 조회 1,754
14년 전 조회 1,677
14년 전 조회 2,547
14년 전 조회 2,485
14년 전 조회 1,434
14년 전 조회 2,363
14년 전 조회 2,804
14년 전 조회 2,215
14년 전 조회 1,458
14년 전 조회 2,852
14년 전 조회 1,646
14년 전 조회 1,431
14년 전 조회 1,382
14년 전 조회 2,128
14년 전 조회 2,492
14년 전 조회 1,982
14년 전 조회 1,449
14년 전 조회 1,674
14년 전 조회 2,177
14년 전 조회 2,107
14년 전 조회 1,447
14년 전 조회 4,224
14년 전 조회 2,116
14년 전 조회 5,286
14년 전 조회 1,674
14년 전 조회 2,663
14년 전 조회 1,732
14년 전 조회 1,625
14년 전 조회 2,526
14년 전 조회 1,527
14년 전 조회 2,480
14년 전 조회 1,586
14년 전 조회 2,338
14년 전 조회 1,865
14년 전 조회 4,912
14년 전 조회 2,875
14년 전 조회 1,735
14년 전 조회 1,594
14년 전 조회 2,176
14년 전 조회 1,791
14년 전 조회 1,873
14년 전 조회 3,000
14년 전 조회 1,587
14년 전 조회 3,771
14년 전 조회 3,682
14년 전 조회 2,008
14년 전 조회 1,690
14년 전 조회 3,132
14년 전 조회 1,798
14년 전 조회 2,049
14년 전 조회 1,514
14년 전 조회 2,621
14년 전 조회 2,006
14년 전 조회 2,076
14년 전 조회 2,355
14년 전 조회 1,493
14년 전 조회 4,574
14년 전 조회 1,782
14년 전 조회 2,646
14년 전 조회 2,120
14년 전 조회 1,562
14년 전 조회 5,547
14년 전 조회 1,412
14년 전 조회 3,518
14년 전 조회 1,819
14년 전 조회 1,532
14년 전 조회 1,948
14년 전 조회 8,663
14년 전 조회 1,873
14년 전 조회 2,893
14년 전 조회 2,355
14년 전 조회 1,920
14년 전 조회 4,989
14년 전 조회 1,603