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,646
14년 전 조회 3,892
14년 전 조회 1,591
14년 전 조회 1,853
14년 전 조회 1,603
14년 전 조회 2,010
14년 전 조회 1,945
14년 전 조회 2,217
14년 전 조회 1,704
14년 전 조회 2,755
14년 전 조회 2,441
14년 전 조회 2,018
14년 전 조회 7,720
14년 전 조회 1,619
14년 전 조회 1,987
14년 전 조회 1,741
14년 전 조회 1,891
14년 전 조회 2,260
14년 전 조회 1,752
14년 전 조회 2,125
14년 전 조회 1,699
14년 전 조회 1,668
14년 전 조회 2,259
14년 전 조회 4,143
14년 전 조회 1,713
14년 전 조회 3,129
14년 전 조회 1,909
14년 전 조회 1,803
14년 전 조회 2,671
14년 전 조회 2,617
14년 전 조회 1,579
14년 전 조회 2,496
14년 전 조회 2,941
14년 전 조회 2,367
14년 전 조회 1,593
14년 전 조회 2,999
14년 전 조회 1,793
14년 전 조회 1,573
14년 전 조회 1,541
14년 전 조회 2,262
14년 전 조회 2,635
14년 전 조회 2,130
14년 전 조회 1,603
14년 전 조회 1,783
14년 전 조회 2,301
14년 전 조회 2,253
14년 전 조회 1,575
14년 전 조회 4,346
14년 전 조회 2,261
14년 전 조회 5,436
14년 전 조회 1,803
14년 전 조회 2,817
14년 전 조회 1,876
14년 전 조회 1,762
14년 전 조회 2,642
14년 전 조회 1,659
14년 전 조회 2,618
14년 전 조회 1,721
14년 전 조회 2,427
14년 전 조회 2,004
14년 전 조회 5,010
14년 전 조회 2,990
14년 전 조회 1,829
14년 전 조회 1,739
14년 전 조회 2,268
14년 전 조회 1,937
14년 전 조회 1,978
14년 전 조회 3,153
14년 전 조회 1,702
14년 전 조회 3,906
14년 전 조회 3,785
14년 전 조회 2,138
14년 전 조회 1,828
14년 전 조회 3,238
14년 전 조회 1,959
14년 전 조회 2,184
14년 전 조회 1,618
14년 전 조회 2,727
14년 전 조회 2,136
14년 전 조회 2,216
14년 전 조회 2,500
14년 전 조회 1,645
14년 전 조회 4,714
14년 전 조회 1,888
14년 전 조회 2,799
14년 전 조회 2,226
14년 전 조회 1,703
14년 전 조회 5,671
14년 전 조회 1,558
14년 전 조회 3,678
14년 전 조회 1,920
14년 전 조회 1,670
14년 전 조회 2,080
14년 전 조회 8,789
14년 전 조회 1,997
14년 전 조회 3,048
14년 전 조회 2,482
14년 전 조회 2,047
14년 전 조회 5,128
14년 전 조회 1,740