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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:24:38+00:00 2026-06-12T00:24:38+00:00

I have this small tabbed system developed in PHP/JavaScript. For form submissioni, I bind

  • 0

I have this small tabbed system developed in PHP/JavaScript.

For form submissioni, I bind a JQuery function to the ‘submit’ event that sends an Ajax query to the server, avoiding to reload the page (and losing other tabs). I have coded one function for every form, but realized that they are the same (take the inputs, send the Ajax query, show the returning message) so I decided to make a general jquery function with arguments that define each form).

I have this function:

function submit_search(entity){
        $('#'+entity.name+'_searchform').submit(function(){
            var url = public_path+entity.name+'/search';
            var key = $('#'+entity.name+'_search_key').val();

            $.ajax({
                type: 'POST',
                url: url,
                data: {search_key: key},
                success: entity.submit_search(result)
            }); 

            return false;
    });
}

Where entity is a JS object with the name of the entity and the success function I want to execute. This function is written in a script that loads once when the main page is loaded. And when the tab is loaded, I simply call submit_search() with the actual entity.

This seems logical to me. But it doesn’t work. And the problem is that jquery doesn’t recognize the elements, by example, after var key = $('#'+entity.name+'_search_key').val();, key is null.

What am I doing wrong?

  • 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-12T00:24:39+00:00Added an answer on June 12, 2026 at 12:24 am

    Your success function will be executed before request

      $.ajax({
                type: 'POST',
                url: url,
                data: {search_key: key},
                success: *entity.submit_search(result)*
            })
    

    I suppose submit_search doesn’t return a pointer to a function so
    you need to pass the pointer to submit_search

      $.ajax({
                type: 'POST',
                url: url,
                data: {search_key: key},
                success: *entity.submit_search*
            })
    

    And about reconginzing the elements – be sure that you wrote correct selector. Try to hardcode expected experssion in browser’s debug/watch tool and check if it’s ok, like

    $('#EntityNameValue_search_key').length > 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this small PHP script that takes a POST variable and writes it
In my c# application i have this small form which is used to set
I have this small script: <? header('Content-Type: text/javascript; charset=utf-8'); $s=L\u00e1szl\u00f3 M\u00e1rton; echo $s; ?>
I have a problem with my index.php, i have this small script that decides
I have this small function that is causing me headaches on RHEL6, and I
I have this small problem with jquery: I need to do something like this:
Say I have this small function in a source file static void foo() {}
peace folks, I have this small piece of jquery based code, that grabs all
I have this small jquery script that does not work if I remove the
I have this small function: // Adds to menu public void addMenuToList(int menuVal, string

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.