如何使用jQuery AJAX将文件从PHP附加到div? [英] How to append a file from PHP to div using jQuery AJAX?

查看:63
本文介绍了如何使用jQuery AJAX将文件从PHP附加到div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script>
jQuery(document).ready(function()
        {
            var str = jQuery(location).attr('href');

         var url = str.split("=")[1];
                jQuery.ajax(
                {
                    type: "GET",
                    url: "http://myfourwalls.in/test/ar_property_details.php?url=" + url,
                    dataType:"JSON",
                    success:function(data)
                    {
                        for(i=0;i<jQuery(data).length;i++)

                        {

                        jQuery('#project_info').append('<p>'+ data[i].project_id + '</p>');
                        jQuery('#project_info').append('<p>'+ data[i].project_name + '</p>');
                        jQuery('#project_info').append('<p>'+ data[i].project_type + '</p>');
                        jQuery('#project_info').append('<img src='+ data[i].project_image + '>');
                        jQuery('#project_info').append('<img src='+ data[i].project_logo + '>');
                        jQuery('#project_info').append('<p>'+ data[i].project_overview + '</p>');
                        jQuery('#project_info').append('<p>'+ data[i].about_builder + '</p>');
                        jQuery('#project_info').append('<p>'+ data[i].project_amenities + '</p>');
                        jQuery('#project_info').append('<p>'+ data[i].exterior_model_name + '</p>');
                        jQuery('#project_info').append('<img src='+ data[i].exterior_model + '>');
                        jQuery('#project_info').append('<p>'+ data[i].interior_model_name + '</p>');
                        jQuery('#project_info').append('<img src='+ data[i].interior_model + '>');
                        jQuery('#project_info').append('<p>'+ data[i].model_360_name + '</p>');
                        jQuery('#project_info').append('<img src='+ data[i].model_360 + '>');
                        }

                    }
            });
        });
</script>



在上面的脚本中,我将.php文件中的所有值都追加到append.At我脚本的末尾,


In the above script,I am getting all the values from .php file to append.At the end of my script I have,

jQuery('#project_info').append('<img src='+ data[i].interior_model + '>');

。这实际上是.wt3文件。它不是在UI中显示。如何在div中显示这个.wt3文件。

我是否需要在jQuery或PHP本身做一些事情?

.This is actually a .wt3 file.It is not showing in UI. How can I display this .wt3 file inside a div.
Do I need to do something in jQuery or in PHP itself?

推荐答案

您实际应该在服务器端读取该文件并将其转换为字符串并将其与数据一起发送。
You should actually read that file in Server side and convert that to string and send it with the data.


这篇关于如何使用jQuery AJAX将文件从PHP附加到div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆