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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:50:00+00:00 2026-05-11T02:50:00+00:00

I am using jQuery and JavaScript, I need to call the jQuery function inside

  • 0

I am using jQuery and JavaScript, I need to call the jQuery function inside my JavaScript code.

My jQuery code:

function display(id){     $.ajax({         type:'POST',         url: 'ajax.php',         data:'id='+id  ,         success: function(data){             $('#response').html(data);         }//success     }); //Ajax      //Here I need to return the ajax.php salary     //return ? } 

My ajax.php file has:

<?php    session_start();     ....     echo '$salary'; ?> 

My JavaScript function has:

my.js  function showName(){     var id = 12;      var a = display(id); //Here I need to call the jQuery function display(). } 

How do I call the jQuery function inside JavaScript code and how do I return the PHP values to jQuery?

  • 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. 2026-05-11T02:50:01+00:00Added an answer on May 11, 2026 at 2:50 am

    I really think you need to separate both things:

    1. A function to trigger the Ajax call.
    2. A function that receive the result from the Ajax call and do whatever you need.

    Like:

    function display(id){   $.ajax({     type:'POST',     url: 'ajax.php',     data:'id='+id  ,     success: anotherFunction; //Ajax response   }); } 

    Then in your my.js code:

    display(2); function anotherFunction(response){     // Here you do whatever you need to do with the response     $('#response').html(data); } 

    Remember that display() will trigger your Ajax call and the code will continue, then when you get your response (maybe some seconds or ms later) anotherFunction() will be called. That’s why Ajax is asynchronous. If you need synchronous calls, check the documentation about jQuery and Ajax technique.

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer string fullAppName = Assembly.GetCallingAssembly().GetName().CodeBase; string fullAppPath = Path.GetDirectoryName(fullAppName); May 11, 2026 at 11:56 pm
  • Editorial Team
    Editorial Team added an answer As Tony didn't provide any comments, let me add details… May 11, 2026 at 11:56 pm
  • Editorial Team
    Editorial Team added an answer Correct answer (thanks to cuke google group) is using --backtrace… May 11, 2026 at 11:56 pm

Related Questions

I am using jQuery to call web service (*.asmx) methods. The web service uses
I have a function defined in AS3 that's gonna be called from client side
I am using methods with the Attribute [WebMethod] in my aspx pages. I don't
I am learning jQuery and have a created several plug ins. Unfortunately due to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.