我想添加一个成功和失败的功能,但我该怎么做呢?我在下面有这段代码:
class ={};
class.hey = function(values)
{
document.getElementById(values.id).innerHTML = values.Val ;
return class;
}
class.hey({
id:"target",
Val: "hello world",//this wil work and will display that value in the span tag
})
<span id="target"></span>//here will appear the value passed before
我如何添加一个函数来告诉我一切是否正常?我一直在尝试,但我无法解决这个 id 是如何工作的示例
class ={};
class.hey = function(values)
{
document.getElementById(values.id).innerHTML = values.Val ;
return class;
}
class.hey({
id:"objetive",//the element does not exist
Val: "hello world",//this wil work and will display that value in the span tag
success:function(msg)
{
alert("ok!")
},
error:function(msg){
alert("wrong");
}
})
<span id="target"></span>//here will appear the value passed before