script type text javascript document ready function btnUploadFile on c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script type="text/javascript">
$(document).ready(function () {
$("#btnUploadFile").on("click", function () {
var data = new FormData(document.forms.project);
var files = $("#fileUpload").get(0).files;
if (files.length > 0) {
data.append("Project", files[0]);
}
var ajaxRequest = $.ajax({
type: "POST",
url: "/api/Build",
contentType: false,
processData: false,
data: data
});
ajaxRequest.done(function (msg) {
$("#result").html(msg);
});
ajaxRequest.fail(function (jqXHR, textStatus) {
$("#result").html("Request failed: " + textStatus);
});
});
});
</script>