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년 전 조회 653
13년 전 조회 2,971
13년 전 조회 682
13년 전 조회 877
13년 전 조회 674
13년 전 조회 1,052
13년 전 조회 992
13년 전 조회 1,249
13년 전 조회 775
13년 전 조회 1,840
13년 전 조회 1,475
13년 전 조회 1,063
13년 전 조회 6,744
13년 전 조회 663
13년 전 조회 1,033
13년 전 조회 869
13년 전 조회 1,019
13년 전 조회 1,303
13년 전 조회 896
13년 전 조회 1,154
13년 전 조회 743
13년 전 조회 768
13년 전 조회 1,287
13년 전 조회 3,156
13년 전 조회 719
13년 전 조회 2,151
13년 전 조회 924
13년 전 조회 822
13년 전 조회 1,713
13년 전 조회 1,640
13년 전 조회 650
13년 전 조회 1,564
13년 전 조회 1,988
13년 전 조회 1,391
13년 전 조회 642
13년 전 조회 2,056
13년 전 조회 854
13년 전 조회 642
13년 전 조회 606
13년 전 조회 1,327
13년 전 조회 1,709
13년 전 조회 1,181
13년 전 조회 675
13년 전 조회 808
13년 전 조회 1,301
13년 전 조회 1,255
13년 전 조회 588
13년 전 조회 3,389
13년 전 조회 1,248
13년 전 조회 4,415
13년 전 조회 823
13년 전 조회 1,805
13년 전 조회 887
13년 전 조회 789
13년 전 조회 1,695
13년 전 조회 675
13년 전 조회 1,632
13년 전 조회 736
13년 전 조회 1,509
13년 전 조회 1,035
13년 전 조회 4,087
13년 전 조회 2,089
13년 전 조회 914
13년 전 조회 728
13년 전 조회 1,297
13년 전 조회 932
13년 전 조회 1,067
13년 전 조회 2,160
13년 전 조회 804
13년 전 조회 2,865
13년 전 조회 2,856
13년 전 조회 1,114
13년 전 조회 814
13년 전 조회 2,353
13년 전 조회 943
13년 전 조회 1,186
13년 전 조회 725
13년 전 조회 1,847
13년 전 조회 1,136
13년 전 조회 1,199
13년 전 조회 1,539
13년 전 조회 641
13년 전 조회 3,715
13년 전 조회 960
13년 전 조회 1,836
13년 전 조회 1,337
13년 전 조회 711
13년 전 조회 4,692
13년 전 조회 563
13년 전 조회 2,677
13년 전 조회 1,018
13년 전 조회 692
13년 전 조회 1,061
13년 전 조회 7,830
13년 전 조회 1,008
13년 전 조회 2,102
13년 전 조회 1,544
13년 전 조회 1,080
13년 전 조회 4,135
13년 전 조회 746
🐛 버그신고