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,688
14년 전 조회 3,915
14년 전 조회 1,619
14년 전 조회 1,903
14년 전 조회 1,644
14년 전 조회 2,055
14년 전 조회 1,988
14년 전 조회 2,248
14년 전 조회 1,753
14년 전 조회 2,781
14년 전 조회 2,495
14년 전 조회 2,052
14년 전 조회 7,769
14년 전 조회 1,659
14년 전 조회 2,017
14년 전 조회 1,781
14년 전 조회 1,928
14년 전 조회 2,305
14년 전 조회 1,775
14년 전 조회 2,155
14년 전 조회 1,743
14년 전 조회 1,704
14년 전 조회 2,322
14년 전 조회 4,196
14년 전 조회 1,760
14년 전 조회 3,177
14년 전 조회 1,957
14년 전 조회 1,845
14년 전 조회 2,745
14년 전 조회 2,658
14년 전 조회 1,627
14년 전 조회 2,549
14년 전 조회 3,005
14년 전 조회 2,414
14년 전 조회 1,640
14년 전 조회 3,044
14년 전 조회 1,848
14년 전 조회 1,630
14년 전 조회 1,592
14년 전 조회 2,308
14년 전 조회 2,688
14년 전 조회 2,185
14년 전 조회 1,653
14년 전 조회 1,830
14년 전 조회 2,340
14년 전 조회 2,308
14년 전 조회 1,617
14년 전 조회 4,385
14년 전 조회 2,299
14년 전 조회 5,474
14년 전 조회 1,846
14년 전 조회 2,853
14년 전 조회 1,923
14년 전 조회 1,809
14년 전 조회 2,680
14년 전 조회 1,713
14년 전 조회 2,665
14년 전 조회 1,762
14년 전 조회 2,457
14년 전 조회 2,051
14년 전 조회 5,033
14년 전 조회 3,018
14년 전 조회 1,863
14년 전 조회 1,782
14년 전 조회 2,296
14년 전 조회 1,985
14년 전 조회 2,003
14년 전 조회 3,202
14년 전 조회 1,726
14년 전 조회 3,946
14년 전 조회 3,812
14년 전 조회 2,180
14년 전 조회 1,862
14년 전 조회 3,262
14년 전 조회 2,001
14년 전 조회 2,236
14년 전 조회 1,645
14년 전 조회 2,750
14년 전 조회 2,193
14년 전 조회 2,261
14년 전 조회 2,550
14년 전 조회 1,676
14년 전 조회 4,760
14년 전 조회 1,919
14년 전 조회 2,856
14년 전 조회 2,263
14년 전 조회 1,748
14년 전 조회 5,720
14년 전 조회 1,606
14년 전 조회 3,716
14년 전 조회 1,955
14년 전 조회 1,726
14년 전 조회 2,127
14년 전 조회 8,853
14년 전 조회 2,040
14년 전 조회 3,096
14년 전 조회 2,538
14년 전 조회 2,100
14년 전 조회 5,176
14년 전 조회 1,792