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,802
14년 전 조회 1,493
14년 전 조회 1,730
14년 전 조회 1,469
14년 전 조회 1,898
14년 전 조회 1,807
14년 전 조회 2,110
14년 전 조회 1,573
14년 전 조회 2,642
14년 전 조회 2,332
14년 전 조회 1,887
14년 전 조회 7,576
14년 전 조회 1,504
14년 전 조회 1,861
14년 전 조회 1,627
14년 전 조회 1,809
14년 전 조회 2,141
14년 전 조회 1,651
14년 전 조회 2,006
14년 전 조회 1,584
14년 전 조회 1,577
14년 전 조회 2,156
14년 전 조회 4,025
14년 전 조회 1,560
14년 전 조회 2,995
14년 전 조회 1,754
14년 전 조회 1,676
14년 전 조회 2,547
14년 전 조회 2,481
14년 전 조회 1,431
14년 전 조회 2,362
14년 전 조회 2,804
14년 전 조회 2,214
14년 전 조회 1,455
14년 전 조회 2,850
14년 전 조회 1,646
14년 전 조회 1,429
14년 전 조회 1,381
14년 전 조회 2,128
14년 전 조회 2,492
14년 전 조회 1,978
14년 전 조회 1,446
14년 전 조회 1,673
14년 전 조회 2,177
14년 전 조회 2,105
14년 전 조회 1,447
14년 전 조회 4,222
14년 전 조회 2,113
14년 전 조회 5,284
14년 전 조회 1,672
14년 전 조회 2,662
14년 전 조회 1,731
14년 전 조회 1,623
14년 전 조회 2,525
14년 전 조회 1,522
14년 전 조회 2,479
14년 전 조회 1,583
14년 전 조회 2,336
14년 전 조회 1,862
14년 전 조회 4,912
14년 전 조회 2,874
14년 전 조회 1,733
14년 전 조회 1,593
14년 전 조회 2,175
14년 전 조회 1,790
14년 전 조회 1,872
14년 전 조회 2,999
14년 전 조회 1,585
14년 전 조회 3,769
14년 전 조회 3,682
14년 전 조회 2,007
14년 전 조회 1,690
14년 전 조회 3,132
14년 전 조회 1,796
14년 전 조회 2,046
14년 전 조회 1,509
14년 전 조회 2,620
14년 전 조회 2,005
14년 전 조회 2,075
14년 전 조회 2,355
14년 전 조회 1,493
14년 전 조회 4,572
14년 전 조회 1,778
14년 전 조회 2,641
14년 전 조회 2,117
14년 전 조회 1,560
14년 전 조회 5,547
14년 전 조회 1,410
14년 전 조회 3,515
14년 전 조회 1,817
14년 전 조회 1,532
14년 전 조회 1,946
14년 전 조회 8,662
14년 전 조회 1,872
14년 전 조회 2,893
14년 전 조회 2,355
14년 전 조회 1,919
14년 전 조회 4,989
14년 전 조회 1,603