Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:09:39+00:00 2026-06-15T06:09:39+00:00

I am trying to write a universal code for AJAX. I will show what

  • 0

I am trying to write a universal code for AJAX. I will show what I mean on the example of the e-shops admin panel. There are some things that we can edit, for example: categories, products, attributes. Each of those elements have its forms with input text and input checkbox fields etc. Saving is going to look like in Gmail, when you write something in the field it is automaticaly sent request to server. For each module (categories, products, attributes…) I have a controller and an action in it for example for edition editAction, for deleting deleteAction etc. It sometimes that I have in one view more than one form concerning controllers. In main layout I have a JS code:

$.ajax({
      url: 'http://localhost/fa.fronted/public/en/controller/action/',
      type: 'POST',
      data: 'websiteid='+iWebId+'&formid='+iFormId+'&formfieldid='+iFieldId+'&'+dataName+'='+dataValue,
      success: function(data) {
          if(data=='OK') {
              $('#ajaxmessage').text('All changes saved');
          }
          else{
              $('#ajaxmessage').text('Error: ' + data);
          }
      },
      error: function() {
          $('#ajaxmessage').text('Error');
      }
  });
}

I would like to use different URL addresses for different controllers and actions – I want to do this dynamicaly or manage it in the form.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:09:40+00:00Added an answer on June 15, 2026 at 6:09 am
    function onChangeCallback(controller,action,formId){
        var data = getFormData(formId); 
        // or if you want to save by field $(this).val() will get you the input value
        // make the ajax request from the code posted in your question
    }
    
    <input type="text" name="username" onchange="return onChangeCallback('<?=$this->ControllerName?>'
    ,'<?=$this->actionName?>','myForm')" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying write code that will maintain the sorting preference while changing page
I m trying write code that after reset set up rrpmax as 3000. It
Trying to write app for service technicians that will display open service calls within
Trying to write a couple of functions that will encrypt or decrypt a file
Trying to write a code at the moment that basically tests to see if
My question is essentially that I am trying to make a universal Ajax function
I am trying to learn python, I was trying write C/C++ code i used
Trying to write a simple jQuery function that will multiple the index of an
Trying to write a piece of code to compare two strings. If either are
I've been trying write an application which will be able to connect to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.