Welcome Guest, Not a member yet? Register   Sign In
Form Submission via Ajax.Updater
#1

[eluser]Narkboy[/eluser]
I've been hammering my head on this for far too long, so I'm giving up and asking for help!

I'm developing an admin section for a site which will consist of a single page that links the various admin sections. Clicking fires an Ajax.Updater to fetch the relevant section and display it in a covering div over the main content.

I can get a form view to be displayed by echo'ing them from the controller, but I cannot work out how to submit that form via Ajax.

Here's the process that I want:
1- User click on an admin section. JS displays the div's and Ajax.Updater fills them. (ok)
2- User fills in the form displayed and submits.
3- JS stops the actual submission, and sends it via Ajax.Updater to a controller function which processes the submission and echo's either validation errors or a sucess msg into the original div.
4- User re-submits or continues.

Here's the view of the form that is loaded into the 'cover' div:
Code:
<h1>Add New Portfolio</h1>

&lt;form name="newPort" action="&lt;?php echo site_url('/admin/insertPort');?&gt;" method="post"&gt;
<table class="adminTable">
    <tr>
        <th>Title</th>
        <td>&lt;input name="title" type="text" class="formText" size="20" maxlength="15" /&gt;&lt;/td>
    </tr>
    <tr>
        <th>Description</th>
        <td>&lt;textarea name="description" class="formText" rows="5" cols="80"&gt;&lt;/textarea></td>
    </tr>
    <tr>
        <th>Display Order</th>
        <td>&lt;input name="order" type="text" class="formText" size="3" maxlength="2" /&gt;&lt;/td>
    </tr>
    <tr>
        <th>Active</th>
        <td>&lt;input name="active" class="formText" type="checkbox" class="formText" /&gt;&lt;/td>
    </tr>
    <tr>
        <td>&lt;input name="reset" type="reset" class="formReset" value="Reset" /&gt;&lt;/td>
        <td>&lt;input name="subNewPort" id="subNewPort" type="submit" class="formSubmit" value="Add Portfolio" /&gt;&lt;/td>
    </tr>
</table>

&lt;/form&gt;
<a href="[removed]changeCover('&lt;?php echo base_url();?&gt;index.php/admin/viewPorts');">View Portfolios</a>
<p class="closeCover">[ <a href="[removed]closeCover();">Exit</a> ]</p>

The onsubmit uses a custom function ajaxSubmit because it has to handle the Ajax.Update as well as several other bits for display purposes.

The Ajax.Updater needs to post a request to admin/insertPort which will call the right parts of the manager model and echo either the form with error msgs or else a success msg.

The bit I can't figure (for a day of trying) is how to fire the Ajax.Updater to include the post data from the form. I can call the controller ok, I just can't include the post data with the call.

I'm using Ajax.Updater so that I don't have to worry about writing functions for Ajax.Request to insert the return data - since the controller will always return something. That said, if this is easier using Ajax.Request, then let me know and explain how!! I'd rather use POST than GET, but again, that can be flexible.

Help!!!

Thanks in advance!

/B


Messages In This Thread
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 04:35 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 06:55 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 06:59 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 07:26 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 07:30 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 07:35 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 08:10 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 08:59 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 10:18 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 10:30 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 10:55 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 11:32 AM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 02:14 PM
Form Submission via Ajax.Updater - by El Forum - 03-12-2009, 03:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB