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년 전 조회 661
13년 전 조회 2,983
13년 전 조회 692
13년 전 조회 892
13년 전 조회 683
13년 전 조회 1,063
13년 전 조회 1,003
13년 전 조회 1,260
13년 전 조회 784
13년 전 조회 1,856
13년 전 조회 1,485
13년 전 조회 1,071
13년 전 조회 6,759
13년 전 조회 671
13년 전 조회 1,042
13년 전 조회 879
13년 전 조회 1,031
13년 전 조회 1,310
13년 전 조회 912
13년 전 조회 1,173
13년 전 조회 753
13년 전 조회 779
13년 전 조회 1,298
13년 전 조회 3,168
13년 전 조회 733
13년 전 조회 2,160
13년 전 조회 936
13년 전 조회 829
13년 전 조회 1,727
13년 전 조회 1,654
13년 전 조회 662
13년 전 조회 1,574
13년 전 조회 1,999
13년 전 조회 1,400
13년 전 조회 654
13년 전 조회 2,067
13년 전 조회 869
13년 전 조회 648
13년 전 조회 620
13년 전 조회 1,337
13년 전 조회 1,718
13년 전 조회 1,189
13년 전 조회 680
13년 전 조회 820
13년 전 조회 1,312
13년 전 조회 1,268
13년 전 조회 599
13년 전 조회 3,398
13년 전 조회 1,253
13년 전 조회 4,425
13년 전 조회 829
13년 전 조회 1,822
13년 전 조회 900
13년 전 조회 804
13년 전 조회 1,706
13년 전 조회 683
13년 전 조회 1,641
13년 전 조회 743
13년 전 조회 1,516
13년 전 조회 1,044
13년 전 조회 4,099
13년 전 조회 2,100
13년 전 조회 925
13년 전 조회 741
13년 전 조회 1,305
13년 전 조회 943
13년 전 조회 1,080
13년 전 조회 2,173
13년 전 조회 815
13년 전 조회 2,881
13년 전 조회 2,866
13년 전 조회 1,126
13년 전 조회 822
13년 전 조회 2,364
13년 전 조회 953
13년 전 조회 1,198
13년 전 조회 735
13년 전 조회 1,859
13년 전 조회 1,151
13년 전 조회 1,208
13년 전 조회 1,558
13년 전 조회 650
13년 전 조회 3,724
13년 전 조회 972
13년 전 조회 1,852
13년 전 조회 1,348
13년 전 조회 722
13년 전 조회 4,707
13년 전 조회 571
13년 전 조회 2,687
13년 전 조회 1,028
13년 전 조회 704
13년 전 조회 1,072
13년 전 조회 7,841
13년 전 조회 1,023
13년 전 조회 2,113
13년 전 조회 1,553
13년 전 조회 1,096
13년 전 조회 4,145
13년 전 조회 754
🐛 버그신고