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년 전 조회 1,226
13년 전 조회 3,553
13년 전 조회 1,264
13년 전 조회 1,457
13년 전 조회 1,210
13년 전 조회 1,611
13년 전 조회 1,539
13년 전 조회 1,832
13년 전 조회 1,312
13년 전 조회 2,428
13년 전 조회 2,054
13년 전 조회 1,624
14년 전 조회 7,310
14년 전 조회 1,228
14년 전 조회 1,597
14년 전 조회 1,370
14년 전 조회 1,585
14년 전 조회 1,882
14년 전 조회 1,434
14년 전 조회 1,728
14년 전 조회 1,332
14년 전 조회 1,354
14년 전 조회 1,871
14년 전 조회 3,746
14년 전 조회 1,292
14년 전 조회 2,726
14년 전 조회 1,492
14년 전 조회 1,397
14년 전 조회 2,290
14년 전 조회 2,209
14년 전 조회 1,183
14년 전 조회 2,108
14년 전 조회 2,552
14년 전 조회 2,033
14년 전 조회 1,186
14년 전 조회 2,592
14년 전 조회 1,400
14년 전 조회 1,191
14년 전 조회 1,110
14년 전 조회 1,888
14년 전 조회 2,243
14년 전 조회 1,748
14년 전 조회 1,186
14년 전 조회 1,412
14년 전 조회 1,889
14년 전 조회 1,934
14년 전 조회 1,178
14년 전 조회 3,958
14년 전 조회 1,852
14년 전 조회 5,086
14년 전 조회 1,404
14년 전 조회 2,384
14년 전 조회 1,448
14년 전 조회 1,369
14년 전 조회 2,271
14년 전 조회 1,263
14년 전 조회 2,228
14년 전 조회 1,323
14년 전 조회 2,099
14년 전 조회 1,619
14년 전 조회 4,665
14년 전 조회 2,657
14년 전 조회 1,508
14년 전 조회 1,327
14년 전 조회 1,911
14년 전 조회 1,539
14년 전 조회 1,662
14년 전 조회 2,730
14년 전 조회 1,368
14년 전 조회 3,467
14년 전 조회 3,453
14년 전 조회 1,734
14년 전 조회 1,417
14년 전 조회 2,919
14년 전 조회 1,530
14년 전 조회 1,800
14년 전 조회 1,280
14년 전 조회 2,406
14년 전 조회 1,738
14년 전 조회 1,812
14년 전 조회 2,080
14년 전 조회 1,228
14년 전 조회 4,293
14년 전 조회 1,537
14년 전 조회 2,392
14년 전 조회 1,898
14년 전 조회 1,287
14년 전 조회 5,282
14년 전 조회 1,140
14년 전 조회 3,243
14년 전 조회 1,605
14년 전 조회 1,268
14년 전 조회 1,665
14년 전 조회 8,416
14년 전 조회 1,579
14년 전 조회 2,630
14년 전 조회 2,101
14년 전 조회 1,676
14년 전 조회 4,722
14년 전 조회 1,339