开发者

Separate html return data in ajax

开发者 https://www.devze.com 2023-01-24 03:47 出处:网络
With the code below is possible to get separate values, using the variable data. I have inside 2 variables content and pagination, and I want to separate them.

With the code below is possible to get separate values, using the variable data. I have inside 2 variables content and pagination, and I want to separate them.

I need and answer that doesn't use JSON.

                  jQuery.ajax({
                type: "POST",
                url: "<?php echo DOMAIN ?>inc/ajax_content/sort-jobs-content.php",
                data: "id_select="+id_select+"&selected_value="+value,
                dataType : "html",
                complete: function () {  },
     开发者_开发百科           success: function(data){


                }
            });


JSON would be best. But if you insist, how about this?

success: function(data){
    var obj = $(data);
    var pagination = obj.find('.pagenation').clone();
    var content = obj.find('.content').clone();
}


@partoa Thank you for your help i finally fixed my problem , just i used closest function , because find is showing finded div and the rest is empty , anyway thank you for your help !

            jQuery.ajax({
                type: "POST",
                url: "<?php echo DOMAIN ?>inc/ajax_content/sort-jobs-content.php",
                data: name_selected+"="+value_element ,
                dataType : "html",
                complete: function () { },
                success: function(data){
                    var obj = jQuery(data);
                    var content_records = obj.closest('div#content_records').clone();
                    var pages = obj.closest('#pages').clone();


                    jQuery("div#records_content").html(content_records);
                    jQuery("div#pages").html(pages);

                    }
                });
0

精彩评论

暂无评论...
验证码 换一张
取 消