2012-11-09 167 views
0

我正在嘗試在mysql中保存數據。通過調用solr url。 它工作在除IE以外的所有瀏覽器中。solr在IE中不工作

我的代碼

dataTable = "<ol>"; 
       //Check the data is present form the searching element. 
       if (data.response.docs.length != 0) { 
        $.each(data.response.docs, function (key, value) { 
         dataTable += "<li><a href=\"" + value.id + "\" onmousedown=\"javascript:StoreClickedURL(" + userId + ",'" + encodeURI(userInput) + "','" + value.id + "')\">" + value.id + "</a></li>"; 
        }); 

        //Check whether persons there or not. 
        dataTable += "</ol>"; 
       } 

功能

function StoreClickedURL(userId, query, event) { 
var urlsearch = "http://192.168.10.113:8080/collective-intellegence/StoreClicks?userid=" + userId + "&query=" + query; 
$.ajax({ 
type: 'POST', 
url: urlsearch, 
dataType: 'json', 
success: function (data) { 
} 
}); 
} 

這在所有的瀏覽器工作正常,但在IE無法正常工作(在IE7,IE8和IE9測試)。

它沒有在任何瀏覽器中顯示任何錯誤。我已經使用Firebug測試過了。

當我點擊一個鏈接時,它會去該函數(通過在函數中放置一個警報進行測試),但不會將數據存儲在數據庫中。

請幫

感謝

+0

可能重複的[跨域AJAX調用不工作在IE(http://stackoverflow.com/questions/13303889/cross-domain-ajax-call-is-not-working-in-ie ) – Jayendra

+0

您是否實現了jsonp選項?這與Solr有什麼關係?它更多的是跨域Ajax調用問題?你甚至不在這裏叫Solr – Jayendra

+0

那麼這是一個腳本問題,而不是solr。打印出查詢字符串,在調用ajax之前和之後,至少應該給你一個提示... –

回答

2

IE不支持跨域Ajax調用我們必須做到這一點像下面的代碼。

if (window.XDomainRequest) // Check whether the browser supports XDR. 
{ 
    xdr = new XDomainRequest(); // Create a new XDR object. 
    if (xdr) { 
     xdr.open("post", urlSearch); 
     xdr.send(); 
    } 
    else { 
     alert('Server Error!! Try Later.'); 
    } 
} 
else { 
    //Inserted data in the database. 
    $.ajax({ 
     type: 'POST', 
     url: urlSearch, 
     dataType: 'json', 
     success: function (data) { 
     } 
    }); 
}