English 中文(简体)
Ajax打电话到火f英的jquery工程,但IE8
原标题:Ajax call from jquery works in firefox but not in IE8
  • 时间:2010-01-10 15:15:52
  •  标签:
  • jquery

I m使用jquery,我向一个网络服务站打电话,接收一些json数据。 这在火ox中是完美的,但出于某种原因,没有在电离层中。

$.ajax({
    type: "GET",
    url: "http://domain.com/Service.svc/data",
    dataType: "json",
    success: function(data) {
        //In firefox this shows the right value of test but in IE8 just "0", why?
        alert(data.d.test);
    }
});

我知道,答复的内容(数据)是:

{"d":{"__type":"MyContent:#","test":888.75,"test2":592.5}}

因此,警报显示,有888.75英寸,但0英方位于互联网探测器。 我看不出为什么发生这种情况?

问题回答

事实是,我E有切身之处:作为标准,或者至少我认为它有藏身之处:假造了正确的数据。 在独立实体中,它始终显示旧的数据。

$.ajax({
    type: "GET",
    url: "http://domain.com/Service.svc/data", cache: false,
    dataType: "json",
    success: function(data) {
        alert(data.d.test);
    }
});

关注这一点,了解情况:

  jQuery.get("http://domain.com/Service.svc/data", 
  function(data) {
      alert(data.d.test);
  },"json");

......

请列入关于您的呼唤的以下备选办法:

data: "{}",
contentType: "application/json; charset=utf-8",

有几个伙伴关系。 http://encosia.com/2008/06/05/3-mistakes-to-aave-time-using-jquery-with-aspnet-ajax/"rel=“nofollow noretinger”Read here。

你可以这样做:

$.ajax({
type: "GET",
url: "http://domain.com/Service.svc/data",
dataType: "json",
success: function(jsondata) {
    data=eval("("+jsondata+")");
    alert(data.d.test);
  }
});

或者,如果你不想使用电子数据,那么就给内容类型“文字/文字”的负责人,或者你可以做一些内容。 类型:“申请/json;charset=utf-8”,如Lance McNearney所言

没有<代码>数据的同一字母的打字 页: 1 提醒大家注意数据是否以正确形式通过。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签