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,696
14년 전 조회 3,918
14년 전 조회 1,621
14년 전 조회 1,912
14년 전 조회 1,646
14년 전 조회 2,061
14년 전 조회 1,992
14년 전 조회 2,255
14년 전 조회 1,757
14년 전 조회 2,783
14년 전 조회 2,502
14년 전 조회 2,056
14년 전 조회 7,776
14년 전 조회 1,665
14년 전 조회 2,023
14년 전 조회 1,786
14년 전 조회 1,933
14년 전 조회 2,312
14년 전 조회 1,779
14년 전 조회 2,161
14년 전 조회 1,747
14년 전 조회 1,708
14년 전 조회 2,328
14년 전 조회 4,201
14년 전 조회 1,765
14년 전 조회 3,183
14년 전 조회 1,963
14년 전 조회 1,855
14년 전 조회 2,751
14년 전 조회 2,663
14년 전 조회 1,632
14년 전 조회 2,553
14년 전 조회 3,009
14년 전 조회 2,417
14년 전 조회 1,650
14년 전 조회 3,050
14년 전 조회 1,854
14년 전 조회 1,636
14년 전 조회 1,596
14년 전 조회 2,314
14년 전 조회 2,689
14년 전 조회 2,189
14년 전 조회 1,663
14년 전 조회 1,830
14년 전 조회 2,346
14년 전 조회 2,317
14년 전 조회 1,624
14년 전 조회 4,390
14년 전 조회 2,303
14년 전 조회 5,482
14년 전 조회 1,856
14년 전 조회 2,859
14년 전 조회 1,926
14년 전 조회 1,817
14년 전 조회 2,683
14년 전 조회 1,720
14년 전 조회 2,668
14년 전 조회 1,765
14년 전 조회 2,463
14년 전 조회 2,058
14년 전 조회 5,039
14년 전 조회 3,023
14년 전 조회 1,870
14년 전 조회 1,792
14년 전 조회 2,299
14년 전 조회 1,991
14년 전 조회 2,009
14년 전 조회 3,208
14년 전 조회 1,732
14년 전 조회 3,950
14년 전 조회 3,815
14년 전 조회 2,185
14년 전 조회 1,866
14년 전 조회 3,265
14년 전 조회 2,007
14년 전 조회 2,243
14년 전 조회 1,649
14년 전 조회 2,754
14년 전 조회 2,197
14년 전 조회 2,266
14년 전 조회 2,557
14년 전 조회 1,683
14년 전 조회 4,766
14년 전 조회 1,929
14년 전 조회 2,863
14년 전 조회 2,265
14년 전 조회 1,754
14년 전 조회 5,727
14년 전 조회 1,609
14년 전 조회 3,720
14년 전 조회 1,965
14년 전 조회 1,734
14년 전 조회 2,129
14년 전 조회 8,863
14년 전 조회 2,047
14년 전 조회 3,105
14년 전 조회 2,540
14년 전 조회 2,108
14년 전 조회 5,180
14년 전 조회 1,794