I have this function on javaScript, and works on Firefox, but on google chrome not
function sendInfo(userId, Code) {
// text with all info to send to controller
var values = {
"token": Code,
"code": userId
}
// POST THE CHANGE HERE TO THE DATABASE
var url = "WSHolFacebook.asmx/saveToken";
$.post(url, values, function (data) {
if (window.ActiveXObject) { return data.xml; }
var xmlString = XMLSerializer().serializeToString(data);
var xml = xmlString,
xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc),
$title = $xml.find("string");
var texto = $title.text();
if ($title.text() == "Success") {
window.location = '<%=ConfigurationManager.AppSettings["successUrl"].ToString() %>'
}
else {
window.location = '<%=ConfigurationManager.AppSettings["errorUrl"].ToString() %>'
}
})
}
the error in chrome it is:
Uncaught TypeError: DOM object constructor cannot be called as a function.
I have this function on javaScript, and works on Firefox, but on google chrome not
function sendInfo(userId, Code) {
// text with all info to send to controller
var values = {
"token": Code,
"code": userId
}
// POST THE CHANGE HERE TO THE DATABASE
var url = "WSHolFacebook.asmx/saveToken";
$.post(url, values, function (data) {
if (window.ActiveXObject) { return data.xml; }
var xmlString = XMLSerializer().serializeToString(data);
var xml = xmlString,
xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc),
$title = $xml.find("string");
var texto = $title.text();
if ($title.text() == "Success") {
window.location = '<%=ConfigurationManager.AppSettings["successUrl"].ToString() %>'
}
else {
window.location = '<%=ConfigurationManager.AppSettings["errorUrl"].ToString() %>'
}
})
}
the error in chrome it is:
Share Improve this question edited Mar 22, 2013 at 15:40 p.s.w.g 149k31 gold badges304 silver badges336 bronze badges asked Mar 22, 2013 at 15:37 r-magalhaesr-magalhaes 4582 gold badges9 silver badges18 bronze badgesUncaught TypeError: DOM object constructor cannot be called as a function.
1 Answer
Reset to default 6Change
var xmlString = XMLSerializer().serializeToString(data);
to
var xmlString = new XMLSerializer().serializeToString(data);
The reason it throws the error is because you are trying to invoke XMLSerializer as a function instead of instantiating it.