jQuery Ajax调用没有找到元素问题 [英] jQuery Ajax call No element found issue

查看:134
本文介绍了jQuery Ajax调用没有找到元素问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试调用ajax方法时在firefox 3.5上收到javascript错误。

I am getting a javascript error on firefox 3.5, when trying to call an ajax method.

请在下面找到错误:

XML Parsing Error: no element found Location: moz-nullprincipal:{1a2c8133-f48f-4707-90f3-1a2b2f2d62e2} Line Number 1, Column 1:

^

这是我的javascript函数:

this is my javascript function:

function Update(Id) {
    $.ajax({
        type: "GET",
        url: ROOT_URL + "/sevice/udates.svc/Update?Id=" + Id,
        success: function(response) {

        },
        async: false
    });
}


推荐答案

ajax调用需要XML返回(可能是由于猜测不好)并尝试解析它并且如果没有返回任何内容或者它是无效的XML则会失败。

The ajax call expects XML back (perhaps due to bad guessing) and tries to parse it and fails if nothing is returned or it is not valid XML..

使用 dataType 选项以指定回复的格式。

Use the dataType option to specify the format of the response.

来自注释看起来有些浏览器无法处理无内容响应。因此,此类案例的解决方法可能是从您的服务中返回一些内容(甚至是单个空格)。

From the comments it looks like some browsers cannot handle an no-content response. So, a workaround for such cases might be to return something from your service (even a single space).

这篇关于jQuery Ajax调用没有找到元素问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆