Я использую jquery ajaxupload плагин для загрузки файлов. У меня есть следующие js на моей странице default.aspx
$(document).ready(function() {
/* Example 1 */
var button = $('#button1'), interval;
new AjaxUpload(button, {
action: 'upload.aspx',
name: 'myfile',
responseType:'json',
onSubmit: function(file, ext) {
// change button text, when user selects file
button.text('Uploading');
// If you want to allow uploading only 1 file at time,
// you can disable upload button
this.disable();
// Uploding -> Uploading. -> Uploading...
interval = window.setInterval(function() {
var text = button.text();
if (text.length < 13) {
button.text(text + '.');
} else {
button.text('Uploading');
}
}, 200);
},
onComplete: function(file, response) {
button.text('Upload');
window.clearInterval(interval);
// enable upload button
this.enable();
// add file to the list
$('<li></li>').appendTo('#example1 .files').text(file);
}
});
}); /*]]>*/</script>
вышеупомянутый js вызовет загрузку страницы upload.aspx.cs. Я ожидаю ответ json от upload.aspx. Но я не понимаю, как мне вернуть ответ от загрузки страницы. Я также попытался изменить действие 'attribute to' upload.aspx / getdata ', где' getdata 'является методом / webmethod, но я все еще вижу, как вызывается загрузка страницы, а не метод / webmethod.
Может ли кто-нибудь помочь мне получить ответ (например, состояние загрузки (успешно / неудачно) в json) и представить его в пользовательском интерфейсе?