【问题标题】:solr is not working in IEsolr 在 IE 中不起作用
【发布时间】:2012-12-20 14:45:48
【问题描述】:

我正在尝试将数据保存在 mysql 中。通过调用 solr url。 它适用于除 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 进行了测试。

当我点击一个链接时,它会转到该函数(通过在函数中放置警报进行测试),但不会将数据存储在数据库中。

请帮忙

谢谢

【问题讨论】:

  • 你实现了 jsonp 选项吗?这与 Solr 有什么关系?它更多的是跨域 Ajax 调用问题?你甚至没有在这里调用 Solr
  • 那么这是一个脚本问题,而不是 solr。在调用ajax之前和之后打印出查询字符串,这至少应该给你一个提示......
  • 我允许我的服务器跨域访问
  • Samuele Sry 我没听懂你

标签: jquery solr


【解决方案1】:

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) {
        }
    });
}

【讨论】:

    猜你喜欢
    • 2012-09-28
    • 1970-01-01
    • 2010-10-30
    • 2011-07-31
    • 2012-05-16
    • 2016-06-01
    • 2012-10-30
    • 2011-02-03
    • 2011-10-07
    相关资源
    最近更新 更多