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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:25:18+00:00 2026-06-13T07:25:18+00:00

I have the next class php: class Job{ public $resultado; public $busqueda; public $wpdb;

  • 0

I have the next class php:

class Job{

    public $resultado;
    public $busqueda;
    public $wpdb;

    public function __construct($busqueda){
        global $wpdb;
        $this->busqueda = $busqueda;
        $this->resultado = array();
        $this->wpdb = $wpdb;
    }   

    public function search_job($resultado){
        $tablepost =$this->wpdb->prefix.'posts';
        $query = "SELECT * from $tablepost WHERE post_type = 'jobman_job' and post_status='publish';";



        if (isset($wpdb)) {
            global $wpdb;
            $result = $wpdb->get_results($query);
        }else{
            $result = $this->wpdb->get_results($query);
        }



        print_r($result);
    }

}

This found ok. Now I would like call the search_function with jQuery .ajax
I try with this:

(function($){

    $('#searchjob').keypress(function(e){
        var search = $.trim($('#searchjob').val());

        if (e.which == "13") {

            $.ajax({
                beforeSend: function(){
                    //$('#loading').html(<img src="rutagif" alt="loading" />);
                },
                url:"../wp-content/themes/SUP2012/class/job.php",
                data:{method: 'search_job', data:{resultado: 'hola'}},
                type: "POST",
                success: function(data){

                }

            }); 
        };

    });

 })(jQuery);

the url parameters respond ok (200 OK), but not retrive information. Any idea?

  • 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-13T07:25:20+00:00Added an answer on June 13, 2026 at 7:25 am

    To make an ajax request in wordpress you should use in functions.php

    add_action('wp_ajax_nopriv_your_function_name', 'your_function_name');
    add_action('wp_ajax_your_function_name', 'your_function_name');
    function your_function_name()
    {
        // do anything here and echo the result
        $data_from_ajax=$_POST['data_to_send_to_server'];
        die(); // last line 
    }
    

    And the javascript should look like

    $('#searchjob').keypress(function(e){
        var your_data = $.trim($(this).val());
        if (e.which == "13") {
            $.ajax({
                type:"POST",
                url: "./wp-admin/admin-ajax.php", // if this file is in a subfolder in your themes folder
                data: {
                    action:'your_function_name', // the function name you used in functions.php
                    data_to_send_to_server:your_data // retrieve from $_POST in php
                },
                success:function(data){
                    // do something with data
                }
            });
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have next php code <?php class A { public function foo() { }
I have the next code: class Printer{ Activity activity; public Printer (Activity activity) {
I have the next code : public class AddPrinter extends ListActivity { @Override public
I have next interface public interface IMyInterface { string this[string key] { get; set;
I have a PHP class with a few static properties like so: static public
I have been working on this form for my php class. I can not
If I have the following simplistic form: <?php class Application_Form_Contact extends Zend_Form { public
I have a class file: class_xx.php. And then a function file: function_xxx.php In my
have a php code like this,(part of the php function here)going to convert it
I have next code require 'rack/rpc' class Server < Rack::RPC::Server def hello_world Hello, world!

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.