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,603
14년 전 조회 3,886
14년 전 조회 1,580
14년 전 조회 1,811
14년 전 조회 1,554
14년 전 조회 1,974
14년 전 조회 1,885
14년 전 조회 2,167
14년 전 조회 1,661
14년 전 조회 2,743
14년 전 조회 2,405
14년 전 조회 1,971
14년 전 조회 7,671
14년 전 조회 1,594
14년 전 조회 1,949
14년 전 조회 1,700
14년 전 조회 1,884
14년 전 조회 2,213
14년 전 조회 1,731
14년 전 조회 2,096
14년 전 조회 1,657
14년 전 조회 1,657
14년 전 조회 2,223
14년 전 조회 4,104
14년 전 조회 1,655
14년 전 조회 3,088
14년 전 조회 1,859
14년 전 조회 1,758
14년 전 조회 2,640
14년 전 조회 2,577
14년 전 조회 1,525
14년 전 조회 2,450
14년 전 조회 2,892
14년 전 조회 2,311
14년 전 조회 1,543
14년 전 조회 2,938
14년 전 조회 1,741
14년 전 조회 1,521
14년 전 조회 1,487
14년 전 조회 2,214
14년 전 조회 2,595
14년 전 조회 2,084
14년 전 조회 1,560
14년 전 조회 1,743
14년 전 조회 2,261
14년 전 조회 2,191
14년 전 조회 1,537
14년 전 조회 4,306
14년 전 조회 2,215
14년 전 조회 5,382
14년 전 조회 1,766
14년 전 조회 2,765
14년 전 조회 1,820
14년 전 조회 1,720
14년 전 조회 2,628
14년 전 조회 1,612
14년 전 조회 2,566
14년 전 조회 1,678
14년 전 조회 2,417
14년 전 조회 1,953
14년 전 조회 5,003
14년 전 조회 2,977
14년 전 조회 1,824
14년 전 조회 1,686
14년 전 조회 2,262
14년 전 조회 1,894
14년 전 조회 1,967
14년 전 조회 3,104
14년 전 조회 1,686
14년 전 조회 3,863
14년 전 조회 3,774
14년 전 조회 2,093
14년 전 조회 1,778
14년 전 조회 3,226
14년 전 조회 1,908
14년 전 조회 2,133
14년 전 조회 1,606
14년 전 조회 2,712
14년 전 조회 2,095
14년 전 조회 2,170
14년 전 조회 2,451
14년 전 조회 1,581
14년 전 조회 4,649
14년 전 조회 1,876
14년 전 조회 2,742
14년 전 조회 2,212
14년 전 조회 1,650
14년 전 조회 5,643
14년 전 조회 1,501
14년 전 조회 3,621
14년 전 조회 1,914
14년 전 조회 1,630
14년 전 조회 2,038
14년 전 조회 8,738
14년 전 조회 1,960
14년 전 조회 2,999
14년 전 조회 2,438
14년 전 조회 2,004
14년 전 조회 5,074
14년 전 조회 1,689