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

  • SEARCH
  • Home
  • 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 8888839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:07:09+00:00 2026-06-14T22:07:09+00:00

I’m working on a PHP / AJAX application and it’s quickly becoming unmanageable! The

  • 0

I’m working on a PHP / AJAX application and it’s quickly becoming unmanageable!

The application is designed to work much like a a desktop application so almost every user action results in an AJAX call.

For every one of these actions I have some jQuery that posts the data to my PHP script and runs a corresponding PHP function that handles the server side actions.

That means in my jQuery file i’ll have something like this:

$('.delete-project').on('click', function(){
     // Ajax request to http://myapp.co.uk/ajax/delete_project
});

$('.delete-user').on('click', function(){
     // Ajax request to http://myapp.co.uk/ajax/delete_user
});

$('.delete-keyword').on('click', function(){
     // Ajax request to http://myapp.co.uk/ajax/delete_keyword
});

I’m sure there is a better way of doing things, but how is it generally done to avoid lots of similar code? The above actions could possible rolled into one ‘delete’ ajax request which posts the item type and a database ID but a lot of my functions post different data and require different parameters so wouldn’t fit so neatly under one jQuery handler.

I’ve tried finding some resources on how an AJAX application should be put together but all I can find is beginner tutorials on making AJAX requests etc, not how to write a scalable AJAX application.

Just to be clear I know how AJAX works, I’m just trying to find the best way of implementing it in terms of reducing the jQuery and PHP needed where possible.

Are there any good resources that deal with this sort of thing?

  • 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-14T22:07:10+00:00Added an answer on June 14, 2026 at 10:07 pm

    You can roll all those into one delete function by using attributes in HTML, for example:

    $('.delete').on('click', function(){
         var delete = $(this).attr('data-delete');
         // Ajax request to http://myapp.co.uk/ajax/delete_{delete}
    });
    

    Then your HTML would be something like:

    <a href="#" class="delete" data-delete="project">Delete</a>
    

    More information on data-attributes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

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.