简体   繁体   English

我该如何追加 <DIV> 标签来自AJAX?

[英]How can I append <DIV> tag which cames from AJAX?

I am new for the Ajax and I am working on the application which provide employee salary as per user input value. 我是Ajax的新手,正在开发按用户输入值提供员工薪水的应用程序。

Now, My question is I am trying to get the data from Ajax in that I wish to display that portion at particular place on my main page 现在,我的问题是我想从Ajax获取数据,因为我希望在主页的特定位置显示该部分。

Let me explain you what I am actually asking for, please have a look: 让我向您解释我的实际要求,请看一下:

<div id=main>
     <div id=1st>
     </div>

     <div id=2nd>
     </div>
</div>
<div>
     <div id=display_result>
     </div>
</div>

above is the sample and I am passing data of id=2nd div & id=display_result div tags which belongs from two different class of CSS and as their own separate position. 上面是示例,我正在传递id = 2nd div和id = display_result div标签的数据,它们分别来自两个不同的CSS类,并作为它们各自的位置。

Here is the actual code in which I am facing the problem. 这是我面临问题的实际代码。

    <div id="find_max_div" class="table-div select-table" style="width:95% !important;">
        <div style="text-align:right;">
            <img width="30px" src="MaxVal_image/close.png" style="margin-right:20px;" class="mousepointer" title="close" name="close1" id="close1">
        </div>
        <div style="display:flex;">
            <div class="position-div-left row_th">
                <div class="position-left"> Enter position: </div>
                <div class="position-right">
                    <input type="text" size="40" name="position" id="position" placeholder="Enter position" class="textbox">
                </div>
            </div>
            <div class="position-div-right row_th" id="same_emp_sal_list-div">
                <div class="position-left"> Select Employee: </div>
                <div class="position-right">
                    <select name="same_sal_emp_list" id="same_sal_emp_list" class="textbox">
                    </select>
                </div>
            </div>
        </div>
        <div id="max_result_table" style="margin-top:12px;">
        </div>
    </div>

I am passing the data from: 我从传递数据:

        <div class="position-div-left row_th">
            <div class="position-left"> Enter position: </div>
            <div class="position-right">
                <input type="text" size="40" name="position" id="position" placeholder="Enter position" class="textbox">
            </div>
        </div>

Try below :- 请尝试以下:-

<div class="result"></div>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
    function refresh_div() {
        jQuery.ajax({
            url:'YOUR PHP page url',
            type:'POST',
            success:function(results) {
                jQuery(".result").html(results);
            }
        });
    }

</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM