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년 전 조회 673
13년 전 조회 2,997
13년 전 조회 707
13년 전 조회 907
13년 전 조회 691
13년 전 조회 1,074
13년 전 조회 1,011
13년 전 조회 1,280
13년 전 조회 796
13년 전 조회 1,866
13년 전 조회 1,497
13년 전 조회 1,086
13년 전 조회 6,766
13년 전 조회 683
13년 전 조회 1,050
13년 전 조회 890
13년 전 조회 1,043
13년 전 조회 1,327
13년 전 조회 919
13년 전 조회 1,185
13년 전 조회 761
13년 전 조회 790
13년 전 조회 1,312
13년 전 조회 3,174
13년 전 조회 738
13년 전 조회 2,171
13년 전 조회 947
13년 전 조회 847
13년 전 조회 1,740
13년 전 조회 1,668
13년 전 조회 676
13년 전 조회 1,584
13년 전 조회 2,008
13년 전 조회 1,418
13년 전 조회 668
13년 전 조회 2,082
13년 전 조회 883
13년 전 조회 665
13년 전 조회 635
13년 전 조회 1,352
13년 전 조회 1,729
13년 전 조회 1,206
13년 전 조회 699
13년 전 조회 833
13년 전 조회 1,323
13년 전 조회 1,278
13년 전 조회 612
13년 전 조회 3,410
13년 전 조회 1,267
13년 전 조회 4,437
13년 전 조회 841
13년 전 조회 1,835
13년 전 조회 921
13년 전 조회 814
13년 전 조회 1,719
13년 전 조회 693
13년 전 조회 1,662
13년 전 조회 749
13년 전 조회 1,532
13년 전 조회 1,061
13년 전 조회 4,120
13년 전 조회 2,112
13년 전 조회 936
13년 전 조회 763
13년 전 조회 1,320
13년 전 조회 964
13년 전 조회 1,092
13년 전 조회 2,188
13년 전 조회 835
13년 전 조회 2,898
13년 전 조회 2,882
13년 전 조회 1,142
13년 전 조회 836
13년 전 조회 2,377
13년 전 조회 967
13년 전 조회 1,219
13년 전 조회 749
13년 전 조회 1,872
13년 전 조회 1,166
13년 전 조회 1,219
13년 전 조회 1,570
13년 전 조회 658
13년 전 조회 3,738
13년 전 조회 989
13년 전 조회 1,861
13년 전 조회 1,361
13년 전 조회 735
13년 전 조회 4,717
13년 전 조회 584
13년 전 조회 2,705
13년 전 조회 1,042
13년 전 조회 716
13년 전 조회 1,089
13년 전 조회 7,860
13년 전 조회 1,035
13년 전 조회 2,119
13년 전 조회 1,562
13년 전 조회 1,106
13년 전 조회 4,157
13년 전 조회 776
🐛 버그신고