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,381
14년 전 조회 3,618
14년 전 조회 1,330
14년 전 조회 1,604
14년 전 조회 1,366
14년 전 조회 1,775
14년 전 조회 1,690
14년 전 조회 1,987
14년 전 조회 1,459
14년 전 조회 2,484
14년 전 조회 2,198
14년 전 조회 1,779
14년 전 조회 7,467
14년 전 조회 1,375
14년 전 조회 1,744
14년 전 조회 1,506
14년 전 조회 1,650
14년 전 조회 2,039
14년 전 조회 1,495
14년 전 조회 1,875
14년 전 조회 1,482
14년 전 조회 1,415
14년 전 조회 2,030
14년 전 조회 3,907
14년 전 조회 1,436
14년 전 조회 2,877
14년 전 조회 1,627
14년 전 조회 1,551
14년 전 조회 2,454
14년 전 조회 2,362
14년 전 조회 1,319
14년 전 조회 2,260
14년 전 조회 2,692
14년 전 조회 2,127
14년 전 조회 1,344
14년 전 조회 2,723
14년 전 조회 1,538
14년 전 조회 1,319
14년 전 조회 1,253
14년 전 조회 2,024
14년 전 조회 2,375
14년 전 조회 1,876
14년 전 조회 1,336
14년 전 조회 1,568
14년 전 조회 2,049
14년 전 조회 2,028
14년 전 조회 1,330
14년 전 조회 4,100
14년 전 조회 2,004
14년 전 조회 5,186
14년 전 조회 1,550
14년 전 조회 2,553
14년 전 조회 1,588
14년 전 조회 1,521
14년 전 조회 2,326
14년 전 조회 1,419
14년 전 조회 2,374
14년 전 조회 1,475
14년 전 조회 2,163
14년 전 조회 1,760
14년 전 조회 4,725
14년 전 조회 2,719
14년 전 조회 1,569
14년 전 조회 1,476
14년 전 조회 1,981
14년 전 조회 1,677
14년 전 조회 1,726
14년 전 조회 2,877
14년 전 조회 1,430
14년 전 조회 3,631
14년 전 조회 3,510
14년 전 조회 1,883
14년 전 조회 1,559
14년 전 조회 2,987
14년 전 조회 1,683
14년 전 조회 1,933
14년 전 조회 1,347
14년 전 조회 2,473
14년 전 조회 1,891
14년 전 조회 1,953
14년 전 조회 2,260
14년 전 조회 1,382
14년 전 조회 4,450
14년 전 조회 1,597
14년 전 조회 2,532
14년 전 조회 1,965
14년 전 조회 1,439
14년 전 조회 5,419
14년 전 조회 1,287
14년 전 조회 3,395
14년 전 조회 1,663
14년 전 조회 1,429
14년 전 조회 1,815
14년 전 조회 8,567
14년 전 조회 1,738
14년 전 조회 2,783
14년 전 조회 2,248
14년 전 조회 1,816
14년 전 조회 4,874
14년 전 조회 1,490