Jump to content

Trouble with J/S - Ajax - Submit Form Fails...


Recommended Posts

Hi Guys,

I'm struggling with a submit form via ajax.

This is the code, but I've been looking for about 3 hours and cannot work out why it doesnt submit the form...

Any ideas?

<script type="application/javascript">
function addForm() {
    $.ajax({type:'POST', url: 'cart.php?ajax=1&a=add&domain=register', data:$('#add-form').serialize(), success: function(response) {

    return false;
function transferForm() {
    $.ajax({type:'POST', url: 'cart.php?ajax=1&a=add&domain=transfer', data:$('#transfer-form').serialize(), success: function(response) {

    return false;

My code is mixed with smarty but the call is just a standard call :)

{foreach from=$availabilityresults key=num item=result}
{if $result.status eq "available"}
<form method="post" id="add-form"  onsubmit="return addForm();">
<form method="post" id="transfer-form"  onsubmit="return transferForm();">
<table width="700" border="0" cellspacing="5" cellpadding="0">
    <input type="hidden" name="domain" value="{$result.domain}" />
    <tr style="border-bottom: #333 1px solid;">
    <td rowspan="2">{if $result.status eq "available"}<img src="templates/dj/yes.jpg" />{else}<img src="templates/dj/no.jpg" />{/if}</td>
    {if $result.status eq "available"}<td style="color:#339933;" />{$result.domain|replace:$domain:''}</td>{else}<td style="color:#cc0000;" />{$result.domain|replace:$domain:''}</td>{/if}
    <td rowspan="2">{$result.domain}</td>
    <td rowspan="2">{if $result.status eq "unavailable"}{else}
    <select name="domainsregperiod[{$result.domain}]">
    {foreach key=period item=regoption from=$result.regoptions}
    	<option value="{$period}">{$period} {$LANG.orderyears} @ {$regoption.register}</option>
    <td rowspan="2">{if $result.status eq "available"}
    <input type="image" src="templates/dj/add-basket.jpg" border="0" alt="Add to Basket" /><div class="form_result"> Added to Basket </div>
    <input type="image" src="templates/dj/transfer.jpg" border="0" alt="Transfer to Us" />
    <td>{if $result.status eq "available"}Available{else}Taken{/if}</td>
  <tr><td colspan="8" style="height:1px; background-color:#999;"></td></tr>
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.