duanhui7329 2015-08-21 11:50
浏览 18

如何解开用php ob_start缓冲的div

In the Middle of a research. How do I unwrap the div with the ID #fromWhere in the php script below. The I was able to do was addClass. Whenever I try to wrap it, it unwraps almost every other element except itself. Any suggestions on how I can achieve this.

<?php   ob_start(); ?>

<div id="fromWhere" >19977</div>

<?php $contents = ob_get_contents(); ?>

In my effort to unwrap it, I changed things over to make it look like below because it work when i tried targeting it from an external script.

<?php   ob_start(); ?>

<script> $('#fromWhere').unwrap(); </script>

<div id="fromWhere" >19977</div>

<?php $contents = ob_get_contents(); ?>

Everything:

PHP

<?php   ob_start(); ?>

<script> $('#fromWhere').unwrap(); </script>

<div id="fromWhere" > </div>

<?php $contents = ob_get_contents(); ?>

             <?php 


        $params = array(
        'origin'        =>  $contents,
        'destination'   => um_user('postal_zip_code'),
        'sensor'        => 'true',
        'units'         => 'imperial'
    );
$params_string='';
    // Join parameters into URL string
    foreach($params as $var => $val){
        $params_string .= '&' . $var . '=' . urlencode($val);  
    }

// Request URL
$url = "http://maps.googleapis.com/maps/api/directions/json?".ltrim($params_string, '&');

// Make our API request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($curl);
curl_close($curl);

// Parse the JSON response
$directions = json_decode($return);

//echo"<pre>";
//print_r($directions);

// Show the total distance
echo '<p><strong>Total distance:</strong> ' . $directions->routes[0]->legs[0]->distance->text . '</p>';

    ?>

                        <div id class="distance"></div>

jQuery that inserts the content into #fromWhere

                    $(document).ready(function() { 

     var from = $('#show-here #from').text();
 $(".approved #fromWhere").text(from);

});
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比