我试图在DOJO编程形式的onSubmit:function()内部调用其余服务,但是,当我单击Submit按钮时,它不显示任何警报值,并且不显示警报数据,而是刷新屏幕并显示回到首页。这是我写的代码
onSubmit: function() {
var repositoryID = this.repotextbox.get('value');
xhr("https://samples.openweathermap.org/data/2.5/weather?q={repositoryID}",{
// The URL of the request
method: "GET",
handleAs: "json",
/* data: {
repoID: repositoryID,
DFMKey: DFM-API-Key
} */
/*query: {
city name: repositoryID
}*/
}).then(
function(data){
alert(data.success + " " + JSON.stringify(data));
},
function(err){
alert( "Your message could not be sent, please try again.");
});
},
感谢任何帮助。