IE的jquery问题...在firefox n chrome中工作正常

时间:2022-10-07 16:17:21

I have a code which accept a query and uses yahoo websearch to return a suggestion.Its working fine in FF and Chrome . but in IE it gives no result. can any one help me on this??

我有一个接受查询的代码,并使用雅虎网络搜索返回一个建议。它在FF和Chrome中运行良好。但在IE中它没有结果。谁可以帮我这个事??

Here is the code:

这是代码:

$(document).ready(function() {

    $.ajax({
        type: 'GET',
        url: "dummyapi.php",
        data: {query: "yaho"},
        success: function(xml) { 
        alert($("Result",xml).text());
        /* do something here */ 
        },
        error: function(xhr, type, exception) { alert("Error: " + type); }
             });
});

dummyapi.php

$Squery = $_GET['query'];
$appid = "S8YhyGzV34HB2jaWxc9VsNIPqeeg0OwqV.WQ0IvF1lblZsUiFzlyEs12kVyH5_IT";
$u = "http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?appid=".$appid."&query=".$Squery;
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $u);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $xml = curl_exec($ch);
            curl_close($ch);
            echo $xml;

2 个解决方案

#1


It seems like you're missing the closing }); of $.ajax, except if it's not shown there.

好像你错过了结束}); $ .ajax,除非它没有在那里显示。

#2


Two quick things that are syntax errors:

两个快速的东西是语法错误:

  • Missing the closing }); of the ajax call (or document.ready, depending on how you look at it)
  • 错过了结束}); ajax调用(或document.ready,取决于你如何看待它)

  • Missing the closing " of the $u variable.
  • 缺少$ u变量的结束。

Just tested the code with these things fixed and it is working for me on IE, FF, Chrome.

刚刚修好了这些代码测试代码,它适用于IE,FF,Chrome。

#1


It seems like you're missing the closing }); of $.ajax, except if it's not shown there.

好像你错过了结束}); $ .ajax,除非它没有在那里显示。

#2


Two quick things that are syntax errors:

两个快速的东西是语法错误:

  • Missing the closing }); of the ajax call (or document.ready, depending on how you look at it)
  • 错过了结束}); ajax调用(或document.ready,取决于你如何看待它)

  • Missing the closing " of the $u variable.
  • 缺少$ u变量的结束。

Just tested the code with these things fixed and it is working for me on IE, FF, Chrome.

刚刚修好了这些代码测试代码,它适用于IE,FF,Chrome。