Jump to content

Ajax post to custom module file returns 404 error


pRieStaKos

Recommended Posts

Hello,

I would like to post a form action with $.ajax, to

modules/addons/custom_folder/actions/setup.php&id={$service.id}

but i get 404 error, on submit.

If I set the form to post to

action="clientarea.php?action=productdetails&id={$service.id}"

the form is submitted successfully. 

<form id="setupForm[{$service.id}]" 
      action="modules/addons/custom_folder/actions/setup.php&sid={$service.id}" 
      index="setupForm" 
      method="post"> 
</form>
$(document).on('click', 'button.submitForm', function(event){ 
  event.preventDefault(); 
  $(this).button('loading'); 
  var form = $(this.form); 
  var indexes = ['reinstallForm', 'consoleButton']; 
  if ($.inArray(form.attr('index'), indexes) !== '-1') { 
    var formData = $(form).serializeArray() 
    var formObj = {} 
    $.each(formData, function (i, input) { 
      formObj['formData[' + input.name + ']'] = input.value; 
    }); 
  } 
  $.ajax({ 
    url: form.attr('action') + 
    '&loadData=' + form.attr('index') + 
    '&namespace=' + form.attr('namespace') + 
    '&index=' + form.attr('index'), 
    type: form.attr('method'),
    processData: false,
    contentType: false,
    data: (jQuery.inArray(form.attr('index'), indexes) !== ' -1') ? jQuery.param(formObj) : $(form).serialize() 
  }).done(function (data) { 
    table.column(5).search("Active").draw(); 
    $('button.submitForm').button('reset').closest('.modal.in').modal('toggle'); 
    if(indexes == 'activateConsoleForm') { 
      checkStatus(); 
    } else { 
      data = data.data 
      if (data.status === 'success') { 
        addAlert(data.status, data.message) 
        setTimeout(function () { // wait for 5 secs 
          location.reload(); // then reload the page. 
        }, 5000); 
      } else { 
        addAlert(data.status, data.message) 
      } 
    } 
  }); 
});

Any suggestions ?

Edited by pRieStaKos
Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated