2013-03-26 234 views
0

我有在HTML文件中的代碼爲一些形狀(其地圖)顯示AJAX工具提示

onclick="top.traeDatos(evt.target.id);" 

的SVG我:

function traeDatos(region){ 
    alert(region); 
} 

所以,我點擊一個地區,我有警告窗口的區域名稱和HTML文件中的變量。這太好了

現在我想要點擊地圖顯示一個彈出式窗口,其中包含更多信息,我將通過一個名爲「getDetails.php」的文件使用來自多個數據庫的ajax。

在js和ajax中,我知道如何在ajax中創建一個標準的調用來獲取一些給定的信息(在本例中是名稱),我知道如何將文本字段的值更改爲文本我得到了ajax調用...但我不明白如何調用ajax並顯示從SVG中的JavaScript代碼或HTML中的工具提示。

林不知道太多的使用什麼tolltip,但在當時一個問題;)

你可以告訴我一點點。

謝謝!

回答

0

這裏是一個開始:

function traeDatos(region){ 
    var domn = document.domain; 
    document.domain = domn; 
    var detURL = "http://" + domn + "/getDetails.php"; 
    $.ajax({ 
     url: detURL, 
     type: 'POST', 
     data: { 
      region: region 
     }, 
     cache: false, 
     success: function(json){ 
      var data = jQuery.parseJSON(json); 
      //using PHP's json_encode() you can return an array 
      //in the example below 'info' is an item in the array 
      $('#insert_place').val(data.info); 
     } 
    }); 
} 

讓我知道,如果你有一些問題與。

+0

我改編它以滿足我的需求,它效果很好。謝謝! – Alejandro 2013-03-27 13:54:44