Unsure why variable is undefined. Possible scope issue?

前端 未结 4 640
夕颜
夕颜 2021-01-26 13:28

If you look at the function below, on line 11 where it alert(template);. It prints undefined. If I alert(template); inside the ajax succes

4条回答
  •  春和景丽
    2021-01-26 14:00

    template isnt defined until your ajax request is completed.

    thats why it shows fine in the success function.

    not sure what framework that is ( JQuery I presume ) but you need to do the callback in the ajax success function.

提交回复
热议问题