无法使用addEventListener将值传递给外部JS文件

时间:2019-02-25 20:49:47

标签: javascript html

  

代码在代码段区域中,试图将值传递给Java脚本   文件

  i am trying to pass a value to a java script file using add event listener  
  not getting any value in return.
  code is in the snippet section of my question
var x = document.get Element By Id("button");
x.  add Event Listener("click", resolve);
var y = document. get Element By Id("x").value;
console.log(x);
console.log(y);
    function resolve()`enter code here`
    {if (y >= 20000)
            {alert("yes greater than 20000");
            } else { alert("no  good");
            }
            }
  this is my code

1 个答案:

答案 0 :(得分:0)

您的代码不是有效的JavaScript。我将其固定在下面:

fetch(URL, 
 {
  credentials: 'include',
  method: 'POST',
  body: JSON.stringify(payload),
  headers: new Headers({
  'Content-Type': 'application/json'
 })
})