douyan1882 2016-11-09 18:08
浏览 82

从数据库查询中回显多个iframe中的数据

I have 6 iframes in one page. A database query populates the first iframe with some rows of data. When I select any one row from this result (based on a unique key), I run another query to the database to get more information about that row.

Now, I want to display different related parts of that information in the other 5 iframes. all the 6 iframes How do I do that?

Technologies used: HTML5/CSS/Javascript/php/SQL Server. Please see attached image for more clarity.

  • 写回答

2条回答 默认 最新

  • doujiexin1136 2016-11-09 19:59
    关注

    This is an answer to the question asked by the original author in the comments of his question

    Can you provide an example of such AJAX call please?

    Without jQuery (Plain JavaScript)

    function getData(url, callback) {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                callback(this.responseText);
            }
        };
        xhttp.open("GET", url, true);
        xhttp.send();
    }
    
    function useData(data) {
        // This is where you are going to use the data to display your page (tables, text, etc...)
        // /!\ `data` is still a string. If you're using JSON for example, don't forget to `JSON.parse()` before using the code.
    
        console.log(data);
    }
    
    // and finally call the getData function with the url and the callback
    getData("myData.php", useData);
    

    Using jQuery:

    function getData(url, callback) {
        $.ajax({
            url: url,
            method: "GET",
            success: callback,
            error: function(xhr, textStatus, errorThrown) {
                alert("AJAX error: " + errorThrown);
            }
        });
    }
    
    function useData(data) {
        // This is where you are going to use the data to display your page (tables, text, etc...)
        // This time, jQuery will do an intelligent guess and automatically parse your data. So wether you're using XML, JSON, ..., it's going to get parsed.
    
        console.log(data);
    }
    
    // and finally call the getData function with the url and the callback
    getData("myData.php", useData);
    
    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services