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개

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

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,328
14년 전 조회 3,583
14년 전 조회 1,302
14년 전 조회 1,566
14년 전 조회 1,316
14년 전 조회 1,714
14년 전 조회 1,640
14년 전 조회 1,931
14년 전 조회 1,414
14년 전 조회 2,456
14년 전 조회 2,159
14년 전 조회 1,732
14년 전 조회 7,415
14년 전 조회 1,324
14년 전 조회 1,704
14년 전 조회 1,469
14년 전 조회 1,613
14년 전 조회 1,993
14년 전 조회 1,468
14년 전 조회 1,828
14년 전 조회 1,425
14년 전 조회 1,383
14년 전 조회 1,973
14년 전 조회 3,865
14년 전 조회 1,390
14년 전 조회 2,828
14년 전 조회 1,589
14년 전 조회 1,495
14년 전 조회 2,406
14년 전 조회 2,317
14년 전 조회 1,281
14년 전 조회 2,211
14년 전 조회 2,639
14년 전 조회 2,094
14년 전 조회 1,297
14년 전 조회 2,677
14년 전 조회 1,495
14년 전 조회 1,273
14년 전 조회 1,215
14년 전 조회 1,983
14년 전 조회 2,332
14년 전 조회 1,845
14년 전 조회 1,289
14년 전 조회 1,519
14년 전 조회 1,992
14년 전 조회 2,004
14년 전 조회 1,283
14년 전 조회 4,063
14년 전 조회 1,954
14년 전 조회 5,162
14년 전 조회 1,492
14년 전 조회 2,508
14년 전 조회 1,542
14년 전 조회 1,474
14년 전 조회 2,302
14년 전 조회 1,359
14년 전 조회 2,328
14년 전 조회 1,429
14년 전 조회 2,130
14년 전 조회 1,712
14년 전 조회 4,697
14년 전 조회 2,687
14년 전 조회 1,543
14년 전 조회 1,428
14년 전 조회 1,953
14년 전 조회 1,628
14년 전 조회 1,695
14년 전 조회 2,830
14년 전 조회 1,401
14년 전 조회 3,582
14년 전 조회 3,490
14년 전 조회 1,827
14년 전 조회 1,521
14년 전 조회 2,962
14년 전 조회 1,633
14년 전 조회 1,891
14년 전 조회 1,313
14년 전 조회 2,438
14년 전 조회 1,846
14년 전 조회 1,911
14년 전 조회 2,205
14년 전 조회 1,325
14년 전 조회 4,397
14년 전 조회 1,568
14년 전 조회 2,479
14년 전 조회 1,932
14년 전 조회 1,398
14년 전 조회 5,378
14년 전 조회 1,239
14년 전 조회 3,348
14년 전 조회 1,642
14년 전 조회 1,384
14년 전 조회 1,764
14년 전 조회 8,526
14년 전 조회 1,693
14년 전 조회 2,741
14년 전 조회 2,206
14년 전 조회 1,770
14년 전 조회 4,825
14년 전 조회 1,447