javascript return value is always undefined

前端 未结 3 1828
名媛妹妹
名媛妹妹 2021-01-07 10:50

I\'m trying to retrieve the 2 attributes of seprated function and I debug there values before the end of the function and they have a value but the return value is alwas und

3条回答
  •  清酒与你
    2021-01-07 11:41

    because function STAAPlanlat doesn't return any value. your anonymous function returns lan but it is asynchronous callback. add this before return lan;:

    document.getElementById("STAAPlanlat").value = "lan is" + lan;
    

提交回复
热议问题