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.
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);
}
});
});
}
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...
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Ok - I found that the files: and iframe: options are not part of the standard jQuery .ajax api - it's something I found on the internet that needs another library to support it - so I abandoned that.
I did get this working nicely with the submit on the form with a iframe as the target. This is what I ended up with in case someone else wants to do an ajax-like upload (without refreshing the page).
and I hooked onto the .LOAD event in JS (the LOAD does happen when the initial HTML gets into the browser - so I have more work to do with FLAGS and such. Probably make this go into a jQuery DIALOG box so I can be in a modal state with more control over the situation.
If you want to go with a MVC framework and you dislike MVC.NET (and don't need all of its bells and whistles), you could try NancyFX.
My work has been using it for a little over a year, and using it with Razor views, it is like a dream. It handles everything we need so far, and is extremely easy to use. One downside, though, is that the only way it currently handles sessions is through a cookie.