Passing an array into a var function
<pre><code>var reguser = function(btn,url,form_data,op) {
    $(btn).click(function(){
        postLoad(url,form_data,op);
        return false;
    });
}

var postLoad = function(url,form_data,op,fade) {
    $.post(base_url(url),form_data,function(q){$(op).html(q);});
}

var getVal = function(link) {
    return $(link).val();
};

var base_url = function(link) {
    return 'http://localhost/cw/' + link;
}
</code></pre>

<p>I have three var function here. I find it odd that when I want to pass on an array variable it doesn't get passed in my AJAX.</p>

<p>Here is how I execute the code (This has been declared in the $(document).ready();). The code above is stored in a separate file.</p>

<pre><code>reguser('#add-acct','ctrl_register/AJAXreguser',{call:1,fname:getVal('#fname')},'#acct-detail');
</code></pre>

<p>The result:</p>

<blockquote>
  <p>Array ( [call] => 1 [fname] => )</p>
</blockquote>

<p>form code</p>

<pre><code>    &lt;form action="http://localhost/cw/ctrl_register" class="form-vertical" method="post" accept-charset="utf-8"&gt;
&lt;label for="fname"&gt;First Name&lt;/label&gt;
    &lt;input type="text" name="fname" value="" class="span8 input-small"id="fname" placeholder="First Name" /&gt;
    &lt;label for="mname"&gt;Middle Name&lt;/label&gt;
&lt;input type="text" name="mname" value="" class="span8 input-small"id="mname" placeholder="Middle Name" /&gt;
&lt;label for="lname"&gt;Last Name&lt;/label&gt;
&lt;input type="text" name="lname" value="" class="span8 input-small"id="lname" placeholder="Last Name" /&gt;
&lt;label for="user"&gt;Username&lt;/label&gt;
&lt;input type="text" name="user" value="" class="span8 input-small"id="user" placeholder="Username" /&gt;
&lt;label for="pass"&gt;Password&lt;/label&gt;
&lt;input type="password" name="pass" value="" class="span8 input-small"id="pass" placeholder="Password" /&gt;
&lt;label for="pass2"&gt;Confirm Password&lt;/label&gt;
&lt;input type="password" name="pass2" value="" class="span8 input-small"id="pass" placeholder="Confirm Password" /&gt;
&lt;/br&gt;&lt;input type="submit" name="Add-acct" value="Add Account" class="btn btn-primary" id="add-acct" /&gt;
&lt;/form&gt;
</code></pre>

<p><img src="http://i.stack.imgur.com/IHBHD.png" alt="enter image description here"></p>
