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 4021582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:22:11+00:00 2026-05-20T10:22:11+00:00

I use WordPress, PHP, jQuery and AJAX. I can get data from PHP through

  • 0

I use WordPress, PHP, jQuery and AJAX.

I can get data from PHP through an AJAX call, like this:

$.ajax({
    type: "POST",
    url: "<?php echo get_bloginfo('url'); ?>/?addmod_ajax=1",
    data: "action=load&type=part",
    success: function(data){
        alert(data);
    }
});

When I have received the data I also want to know how it went. The “data” contains HTML and I also want error codes like “success” or “not-found”.

How do I solve it the best way?

WordPress

Because I use WordPress I need to call a AJAX trigger (in the url). If I could keep that intact it would be nice.

  • 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-05-20T10:22:12+00:00Added an answer on May 20, 2026 at 10:22 am
    $.ajax({
        type: "POST",
        url: "<?php echo get_bloginfo('url'); ?>/?addmod_ajax=1",
        data: "action=load&type=part",
        success: function(data){
            alert(data);
        },
        failure: function(){
            alert('failed');
        }
    });
    

    You could add a failure handler to see if the ajax request is failed, but other than that, if want a different return value, you will have to change the result of the function you are calling on the backend, or create a new similar function that instead of just returning the html, returns a json encoded array with the first element being found or not found, and the second element being the html.

    Edit: Appended comment to complete answer and format code.

    at the place where you echo ‘your result’, you can echo instead

    json_encode(array('success'=>true,'html'=>$yourData)); 
    

    and in your ajax call, add

     dataType:'json'
    

    then you can access the success and html values in your success handler.

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

Sidebar

Related Questions

How can I use something like jQuery & PHP to reorder elements within an
In my case I use jQuery and PHP. I can add data width jQuery
I am moving a site from normal php to wordpress and currently they use
I'm using Wordpress and I would like to use the value of <?php bloginfo('url');
We use a data acquisition card to take readings from a device that increases
I am trying to use the Post Method in my jquery code but it
I have a bunch of jQuery Ajax calls on my WordPress website. After making
In order to make use of a particular jQuery menu in WordPress, I need
i use win7 + VS2008 PRO to edit my blog (php) and i can't
I'm fiddling with a WordPress theme. I'm aware I can use wp_enqueue_script in my

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.