douken1726 2014-12-22 12:37
浏览 16

如何在其他PHP页面上获得ajax成功响应?

I have php page.

On that page, there is dropdown to select cities.These cities are appearing from databases.

Next to that drop down.i have button to add more cities.On click of that button,a pop up(colorbox) appears in which i have form to add new city.

Now what i want is that when i add city in that pop up,that city must also appear in that dropdown of cities after closing that pop up box.

i tried to use ajax and that ajax gives me response.

Whenever i add a new city.That city is added and i got that city and others in that response.

But i can't send that success data to other PHP page.

How can i do that?

This is the functions that sends request to other page and get all cities(already added city and recently added) But i can send that response to other page where i want to populate that cities dropdown with this ajax call response.

function executeQuery() {
  $.ajax({
    url: '<?php echo WEB_URL; ?>pages/reload_fields.php?chk=vessel',
    success:function(result)
                        { 
                            $("<?php echo WEB_URL; ?>pages/add_report_entry.php#refreshPG").html(result);

                        }
  });
  setTimeout(executeQuery, 5000); // you could choose not to continue on failure...
}   
  • 写回答

3条回答 默认 最新

  • dqx24298 2014-12-22 12:44
    关注

    Why would you need to run an AJAX hook to populate a dropdown? Why not just call the function and loop through the results:

    <select>
    <?php
    $cities = function_that_returns_cities();
    
    foreach ($cities as $city) {
    ?>
      <option><?php echo $cities['name']; ?></option>
    <?php } ?>
    </select>
    

    Something like this for example.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法