Results 1 to 6 of 6

Thread: [RESOLVED] Ajax upload confusion

Threaded View

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Resolved [RESOLVED] Ajax upload confusion

    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.

    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>
    I'm trying to switch it to this JavaScript.

    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);
                        }
                    });
                });
            }
    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...
    Attached Images Attached Images  

    *** 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".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width