채택완료

ajax json 질문드립니다!

2021-09-28 (화) 22:03:10 1,703
Copy
function goods_detail_load_origin(goods_nid, ad_nid) {

        var post_url = 'include/goods_detail.ajax.html';

        $.ajax({

            type: "POST",

            dataType: 'json',

            url: post_url,

            data: 'goods_nid=' + goods_nid + '&ad_nid=' + ad_nid,

            success: function(data){

            //alert(data);

                if(data.nid > 0) {

                    $('html').css('overflow','hidden');

 

                    $("#goods_detail #df_goods_name").html( data.df_goods_name );

                    $("#goods_detail #df_goods_comment").html( data.df_goods_comment );

                    $("#goods_detail #df_category").html( data.df_category );

                    $("#goods_detail #df_area").html( data.df_area );

                    $("#goods_detail #df_target").html( data.df_target );

 

                    $("#goods_detail #df_limit_price").html( data.df_limit_price + ' 이내');

                    $("#goods_detail #df_year_rate").html( data.df_year_rate );

                    $("#goods_detail #df_over_rate").html( data.df_over_rate );

                    $("#goods_detail #df_repay_rate").html( data.df_repay_rate );

                    $("#goods_detail #df_action_time").html( data.df_action_time );

                    if (data.df_return_period == '상담후협의')

                    {

                        $("#goods_detail #df_return_period").html( data.df_return_period );

                    }else{

                        $("#goods_detail #df_return_period").html( data.df_return_period + ' 이내');

                    }

 

                    $("#goods_detail #df_return_type").html( data.df_return_type );

                    $("#goods_detail #df_document").html( data.df_document );

 

                    $("#goods_detail #loan_corp_name").html( data.loan_corp_name + data.opening_check);

                    $("#goods_detail #ad_tel1").html( data.ad_tel1 );

                    $("#goods_detail #ad_tel1_btn").html( data.ad_tel1_btn );

                    $("#goods_detail #ad_tel1_url").attr('href', 'tel:'+data.ad_tel1);


 

                    $("#goods_detail #homepage, #goods_detail #homepage_url").html( data.homepage );

                    if( data.homepage_btn ){

                        $("#goods_detail #homepage, #goods_detail .homepage_url").attr( {"href":data.homepage, 'target':'_blank'} );

                        $('.homepage_url_img').css('display','inline-block')

                    }else{

                        $("#goods_detail #homepage, #goods_detail .homepage_url").attr( {"href":'###', 'target':''} );

                        $('.homepage_url_img').css('display','none')

                    }

                    $("#goods_detail #homepage_btn").html( data.homepage_btn );

                    $("#goods_detail #ceo").html( data.ceo );

                    $("#goods_detail #loan_reg_no").html( data.loan_reg_no );

                    $("#goods_detail #part_name").html( data.part_name );

                    $("#goods_detail #part_tel").html( data.part_tel );

                    $("#goods_detail #address").html( data.address );

                    $("#goods_detail #opening_info").html( data.opening_info );

                    $("#goods_detail #smatch_btn").html( data.smatch_btn );

                    if( data.loan_corp_logo ) {

                        $("#goods_detail .infobox02").removeClass('logo_no');

                        $("#goods_detail #logo_img").attr("src", data.loan_corp_logo);

                    } else {

                        $("#goods_detail .infobox02").addClass('logo_no');

                        $("#goods_detail #logo_img").attr("src", $("#goods_detail #logo_img").attr("data-src"));

                    }

 

                } else {

                    alert("대출상품 데이터를 가져오는데 실패했습니다.");

                }

            }

        });

}

공부중인데 이 코드를 토대로 goods_detail.ajax.html 파일을 작성하려고 하는데 감이 안잡히네요 ㅠ

|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트

구글링 해보시고 참조해서 만드세요..

https://www.walterz.net/2017/07/18/jquery-php-json-%EB%B0%A9%EC%8B%9D%EC%9D%98-ajax-%EA%B5%AC%ED%98%84-%EB%B0%A9%EB%B2%95/

data.df_goods_name 와 같은 값들을 넘겨서 받아야 합니다.

답변에 대한 댓글 1개

2021-09-29 (수) 18:07:06
넵 감사합니다 !

답변을 작성하려면 로그인이 필요합니다.