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개

일단 츄쳔해써욤
감사합니다.
추천합니다..
추천합니다.
감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 678
13년 전 조회 3,004
13년 전 조회 715
13년 전 조회 911
13년 전 조회 698
13년 전 조회 1,080
13년 전 조회 1,022
13년 전 조회 1,282
13년 전 조회 806
13년 전 조회 1,871
13년 전 조회 1,503
13년 전 조회 1,093
13년 전 조회 6,775
13년 전 조회 690
13년 전 조회 1,055
13년 전 조회 896
13년 전 조회 1,048
13년 전 조회 1,331
13년 전 조회 924
13년 전 조회 1,189
13년 전 조회 768
13년 전 조회 793
13년 전 조회 1,316
13년 전 조회 3,178
13년 전 조회 747
13년 전 조회 2,179
13년 전 조회 953
13년 전 조회 855
13년 전 조회 1,748
13년 전 조회 1,677
13년 전 조회 687
13년 전 조회 1,592
13년 전 조회 2,016
13년 전 조회 1,424
13년 전 조회 672
13년 전 조회 2,087
13년 전 조회 892
13년 전 조회 668
13년 전 조회 640
13년 전 조회 1,359
13년 전 조회 1,738
13년 전 조회 1,216
13년 전 조회 707
13년 전 조회 839
13년 전 조회 1,328
13년 전 조회 1,286
13년 전 조회 617
13년 전 조회 3,418
13년 전 조회 1,276
13년 전 조회 4,444
13년 전 조회 848
13년 전 조회 1,841
13년 전 조회 925
13년 전 조회 821
13년 전 조회 1,729
13년 전 조회 698
13년 전 조회 1,668
13년 전 조회 758
13년 전 조회 1,543
13년 전 조회 1,064
13년 전 조회 4,128
13년 전 조회 2,124
13년 전 조회 942
13년 전 조회 767
13년 전 조회 1,332
13년 전 조회 972
13년 전 조회 1,100
13년 전 조회 2,193
13년 전 조회 843
13년 전 조회 2,904
13년 전 조회 2,893
13년 전 조회 1,150
13년 전 조회 849
13년 전 조회 2,385
13년 전 조회 972
13년 전 조회 1,229
13년 전 조회 758
13년 전 조회 1,878
13년 전 조회 1,174
13년 전 조회 1,227
13년 전 조회 1,575
13년 전 조회 672
13년 전 조회 3,746
13년 전 조회 996
13년 전 조회 1,873
13년 전 조회 1,369
13년 전 조회 742
13년 전 조회 4,722
13년 전 조회 589
13년 전 조회 2,713
13년 전 조회 1,050
13년 전 조회 722
13년 전 조회 1,096
13년 전 조회 7,865
13년 전 조회 1,040
13년 전 조회 2,125
13년 전 조회 1,568
13년 전 조회 1,110
13년 전 조회 4,164
13년 전 조회 781
🐛 버그신고