How can I pass an object in addition to json from my ajax function?
<p>I have the following code:</p>

<pre><code>function submitHandler(dialog) {

    dialog.$submits.disableBt();
    dialog.$message.addMessage("loading", "&lt;li&gt;Contacting Server, please wait ...&lt;/li&gt;");
    $.ajax({
        url: href,
        dataType: 'json',
        type: 'POST',
        data: dialog.$form.serializeArray()
    })
        .done(onSubmitDone())
        .fail(onSubmitFail());
}
</code></pre>

<p>This function has a parameter of dialog which is an object looking like this:</p>

<pre><code>{
        $modal: $modal,
        $form: $modal.find('.form'),
        $message: $modal.find('.message'),
        $submits: $modal.find('.submit-button'),
        href: $form.attr('data-href')
    };
</code></pre>

<p>I need to send the dialog object to the onSubmitDone and onSubmitFail functions. Previously I was not using an object
to hold $modal, $form etc and the variables were all available to all functions that were enclosed within an outer function</p>

<p>Two questions:</p>

<p><strong>Is it sensible to pass things around as parts of an object or should I just declare these variables at the top of an outer function.</strong> </p>

<p>If I do pass around the object how can I pass it to the following:</p>

<pre><code>function onSubmitDone(json) {
    json = json || {};
    if (json.Success) {
        switch (action) {
</code></pre>

<p>I understand that my json object is passed but how can I pass the dialog object also?</p>
