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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:15:03+00:00 2026-06-04T14:15:03+00:00

I am making a jquery post request to obtain a part of the html

  • 0

I am making a jquery post request to obtain a part of the html code from server. There is a file on server get_info.php which prints html code for different requirements. I am using following code to do this :

function check(inf_type) {
    $.ajax({
        type: 'POST',
        url: "get_info.php",
        data: { "sequence_no" : 1 },
        success: function(data) {
            // how can i use value of variable "inf_type" here.
            // here, the variable "data" contains HTML code.
        },
        dataType: 'text'
    });
}

the function check() accepts a parameter inf_type which contains random strings according to which, server recognize the html code to print. Now, i want handle the POST response according to this inf_type.
How can i access the value of inf_type variable in POST response function? The function check() is called more often, thats why i can not put the inf_type variable value in any global variable.
What can i do to achieve that?
Please guide me. thanks in advance.

  • 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-04T14:15:06+00:00Added an answer on June 4, 2026 at 2:15 pm

    You can access it via inf_type parameter of the check() function:

    function check(inf_type) {
        $.ajax({
            type: 'POST',
            url: "get_info.php",
            data: { "sequence_no" : 1 },
            success: function(data) {
                if (inf_type == 0) {
                    // do something with data
                } else {
                    // do something else
                }
            },
            dataType: 'text'
       });
    

    }

    The reason why this works is because the inner function (success callback) has access to variables in the outer function (check). See this answer for more details: https://stackoverflow.com/a/111200/69868

    Edit
    This assumes that inf_type is a either a number or a new (different) instance of object in each call of check(). Details are explained in the link mentioned above.

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

Sidebar

Related Questions

I'm making a jQuery Ajax POST request to a PHP script that returns an
I am making an ajax request from a jquery script to one of my
I am using struts2 and jquery I am making a server request using XMLHttpRequest
Going slightly crazy here. I'm making an Ajax call using jQuery.post as follows: $.post('php/print.php',{data:dS},function(res){...
I'm making a simple POST request via jquery's .ajax function to a routed URL
I'm making an ajax call using jQuery as below. $.ajax({ type: POST, url: proc.php,
I have some jQuery code in an external Javascript file that is making an
I am making a POST request from IE using XDomainRequest . XDomainRequest does not
I'm doing a pretty simple thing here, making a POST request to Django from
I have been making calls to php from javascript with the jquery $.ajax({}). I

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.