所以我试图解析用户通过文件选择器选择的XML文件。我遇到的问题是我的输入更改事件,jquery没有被调用。
$('input[type=file]').change(function(e){
path = $(this).val();
$.ajax({
type: "GET",
url: path,
dataType: "xml",
success: parseXml
});
});
function parseXml(xml) {
head = xml;
alert('I reached here');
}
答案 0 :(得分:0)
执行:
$(document).ready(function() {
$("input[type='file']").blur(function(){
var path = $(this).val();
alert(path);
$.ajax({
type: "GET",
url: path,
dataType: "xml",
success: function(response) {
parseXml(response);
}
});
});
});
function parseXml(xml) {
//parse here
}