Ok - I've got this HTML - and it's working - dumping the return results into target="upload_target". Originally it was causing my page to reload - or dump into a new tab of the browser - until I found the TARGET setting.
I'm trying to switch it to this JavaScript.
This function does work - properly processing the return results instead of dumping them into a single target. Problem is that this function tries to reload the page.
I can't even find jQuery docs that talk about the FILES: and IFRAME: options.
Very confused here...
Code:
<form id="upload" action="Upload.ashx" method="post" enctype="multipart/form-data" target="upload_target">
<div>
<label>
<input type="file" name="file" multiple>
</label>
<br /><br />
<button type="submit" class="acs-upload-button ui-button ui-widget ui-state-highlight ui-corner-all ui-button-text-icon-acs-use ui-button-text-icon-primary" role="button" aria-disabled="false">Upload</button>
</div>
<iframe id="upload_targe" name="upload_target"></iframe>
</form>
Code:
function initFileUploader(strId) {
$("form").on("click", "button[type=submit]", function (evt) {
$.ajax("Upload.ashx", {
files: $(this).parent().find(":file"),
iframe: true
}).complete(function(data) {
var returnObj = $.parseJSON(data.responseText);
var updArr = returnObj.update || [];
var strData = "";
var wesAWC = [];
for (var i = 0; i < updArr.length; i = i + 2) {
strData = updArr[i + 1];
wesAWC = $("#" + strId + " .awc-" + updArr[i]).not(".acs-edit-view-hidden");
p_fillField(wesAWC, strData, strId, updArr[i], false);
}
if (returnObj.ok) {
errorMessage("Upload Complete", returnObj.message);
} else {
errorMessage("Upload DID NOT Complete", returnObj.message);
}
});
});
}
I can't even find jQuery docs that talk about the FILES: and IFRAME: options.
Very confused here...