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,699
14년 전 조회 3,918
14년 전 조회 1,621
14년 전 조회 1,913
14년 전 조회 1,650
14년 전 조회 2,064
14년 전 조회 1,993
14년 전 조회 2,255
14년 전 조회 1,757
14년 전 조회 2,785
14년 전 조회 2,503
14년 전 조회 2,058
14년 전 조회 7,777
14년 전 조회 1,666
14년 전 조회 2,024
14년 전 조회 1,791
14년 전 조회 1,933
14년 전 조회 2,312
14년 전 조회 1,779
14년 전 조회 2,163
14년 전 조회 1,748
14년 전 조회 1,710
14년 전 조회 2,328
14년 전 조회 4,204
14년 전 조회 1,768
14년 전 조회 3,185
14년 전 조회 1,963
14년 전 조회 1,855
14년 전 조회 2,752
14년 전 조회 2,664
14년 전 조회 1,633
14년 전 조회 2,556
14년 전 조회 3,011
14년 전 조회 2,417
14년 전 조회 1,650
14년 전 조회 3,052
14년 전 조회 1,856
14년 전 조회 1,639
14년 전 조회 1,597
14년 전 조회 2,316
14년 전 조회 2,689
14년 전 조회 2,190
14년 전 조회 1,663
14년 전 조회 1,831
14년 전 조회 2,347
14년 전 조회 2,320
14년 전 조회 1,626
14년 전 조회 4,391
14년 전 조회 2,304
14년 전 조회 5,483
14년 전 조회 1,857
14년 전 조회 2,861
14년 전 조회 1,927
14년 전 조회 1,822
14년 전 조회 2,684
14년 전 조회 1,722
14년 전 조회 2,670
14년 전 조회 1,768
14년 전 조회 2,463
14년 전 조회 2,060
14년 전 조회 5,040
14년 전 조회 3,024
14년 전 조회 1,872
14년 전 조회 1,794
14년 전 조회 2,301
14년 전 조회 1,991
14년 전 조회 2,013
14년 전 조회 3,209
14년 전 조회 1,733
14년 전 조회 3,951
14년 전 조회 3,817
14년 전 조회 2,185
14년 전 조회 1,866
14년 전 조회 3,267
14년 전 조회 2,009
14년 전 조회 2,246
14년 전 조회 1,652
14년 전 조회 2,754
14년 전 조회 2,198
14년 전 조회 2,269
14년 전 조회 2,559
14년 전 조회 1,684
14년 전 조회 4,767
14년 전 조회 1,931
14년 전 조회 2,863
14년 전 조회 2,266
14년 전 조회 1,756
14년 전 조회 5,730
14년 전 조회 1,609
14년 전 조회 3,720
14년 전 조회 1,965
14년 전 조회 1,734
14년 전 조회 2,130
14년 전 조회 8,865
14년 전 조회 2,048
14년 전 조회 3,105
14년 전 조회 2,540
14년 전 조회 2,110
14년 전 조회 5,182
14년 전 조회 1,794