TypeError:无法读取null的属性'documentElement'。 [英] TypeError:Cannot read property 'documentElement' of null.

查看:340
本文介绍了TypeError:无法读取null的属性'documentElement'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有java脚本函数,其中我对我的Web服务进行了jquery ajax调用以获取反向数据。此功能适用于浏览器IE9但在其他浏览器(chrome,opera)上也会出现错误,包括IE10。



  function  DataRequest()
{

$ .ajax({type: POST
url:Wurl,
data:bhrequest,
timeout: 10000
contentType: text / xml
datatype : xml
beforeSend: function (xhr){
xhr.setRequestHeader( SOAPAction http://www.demo.com/Webservice);
},
成功: function (结果,状态){
OnCompleteCustomer(result);
},
错误: function (xhr,status,error){
alert(error);
}
});
}





这里 Wurl 是服务的网址。 bhrequest 是发送到服务的数据参数, OnCompleteCustomer 是成功后调用的方法。

但它出错并抛出 mansion 提到的错误。



上面的错误解决方法是不设置响应的数据类型。数据类型参数留空



我调试我的代码并获得结果,它在IE9浏览器上的结果成功函数的参数中得到结果字符串。

但是在Chrome中结果字符串是空白的

请告诉我它背后的原因是什么。

解决方案

.ajax({type: POST
url:Wurl,
数据:bhrequest,
超时: 10000
contentType: text / xml
数据类型: xml
beforeSend: function (xhr){
xhr.setRequestHeader( SOAPAction http://www.demo.com/Webservice);
},
成功: function (结果,状态){
OnCompleteCustomer(result);
},
错误: function (xhr,status,error){
alert(error);
}
});
}





这里 Wurl 是服务的网址。 bhrequest 是发送到服务的数据参数, OnCompleteCustomer 是成功后调用的方法。

但它出错并抛出 mansion 提到的错误。



上面的错误解决方法是不设置响应的数据类型。数据类型参数留空



我调试我的代码并获得结果,它在IE9浏览器上的结果成功函数的参数中得到结果字符串。

但在Chrome中,结果字符串为空白

请告诉我背后的原因是什么。


< blockquote>好的,你在bhrequest变量中得到了什么?

我认为错误在 bhrequest 变量中。



尝试将参数值硬编码到上面提到的变量并检查它。



否则尝试更新错误抛出代码,以便我们可以试着帮助你。



希望这会有所帮助你出去了。



问候,

RK


I have java script function in which i made jquery ajax call to my web services for retrive data. This function work well with browser IE9 but throw an error on other browser(chrome, opera) including IE10 also.

function DataRequest()
{
     
      $.ajax({ type: "POST",
                url: Wurl,
                data: bhrequest,
                timeout: 10000,
                contentType: "text/xml",
                datatype: "xml",
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("SOAPAction", "http://www.demo.com/Webservice");
                },
                success: function(result, status){
                    OnCompleteCustomer(result);
                },
                error: function (xhr, status, error) {
                    alert(error);
                }
            });
}



Here Wurl is the url of services. bhrequest is data parameters send to services and OnCompleteCustomer is method calling after successful.
but it's gone on error and thrown above mansion mentioned error.

Above error solve by don't setting datatype for response. data type parameter leave blank

I debug my code and got the result,that it's get result string in result argument of success function on IE9 browser.
But in Chrome the result string is blank.
Please tell me what is the reason behind it.

解决方案

.ajax({ type: "POST", url: Wurl, data: bhrequest, timeout: 10000, contentType: "text/xml", datatype: "xml", beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://www.demo.com/Webservice"); }, success: function(result, status){ OnCompleteCustomer(result); }, error: function (xhr, status, error) { alert(error); } }); }



Here Wurl is the url of services. bhrequest is data parameters send to services and OnCompleteCustomer is method calling after successful.
but it's gone on error and thrown above mansion mentioned error.

Above error solve by don't setting datatype for response. data type parameter leave blank

I debug my code and got the result,that it's get result string in result argument of success function on IE9 browser.
But in Chrome the result string is blank.
Please tell me what is the reason behind it.


Ok, What do you get in bhrequest variable?
I think the error is in bhrequest variable.

Try to hard code parameter value to the above mentioned variable and check it.

Otherwise try to update the error throwing code so that we could try to help you out.

Hope this helps you out.

Regards,
RK


这篇关于TypeError:无法读取null的属性'documentElement'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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