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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:50:55+00:00 2026-05-21T05:50:55+00:00

I have 2 questions : If i send the ajax request to self page

  • 0

I have 2 questions :

If i send the ajax request to self page (from abc.php to abc.php) like this :

$.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 });

What will msg variable contain if I have a full webpage (with div’s , forms, imgs) ? Will it contain the whole html code source ? How to tell ajax to return only specific details (like for example a php $variable after querying a database for a record based on Name and Location) . Remember some.php is the same file that contains the ajax script.

I want to make a .php script that contains all querys posible to manage a database like this:

if(isset($_GET['option']) && $_GET['option'] == 'insert') { code here .. and echo div`s .. etc) }
if(isset($_GET['option']) && $_GET['option'] == 'del') { code here .. and echo div`s .. etc) }
if(isset($_GET['option']) && $_GET['option'] == 'update') { code here .. and echo div`s .. etc) }
if(isset($_GET['option']) && $_GET['option'] == 'find') { code here .. and echo div`s .. etc) }
if(isset($_GET['option']) && $_GET['option'] == 'abc') { code here .. and echo div`s .. etc) }

and i want to run ajax request based on option and retrive specific results (like php $variables … and so on)

How do i do that ?

Anyway the most important question is how to i get ajax.result that contain just a php $variable or an $array if the page that receive ajax request already contains <html><body><divs><tables><h4><h3>.... etc ?

Because jquery.ajax() has a documentation quite complex/complicated on it’s options like accepts, async, complete, contentType, context .. and so on.

?

Thanks a lot.

  • 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-21T05:50:55+00:00Added an answer on May 21, 2026 at 5:50 am

    You can use the dataType option to specify the type of data that you are expecting back from the server. In your case JSON might be a good option since the php page can return a String in the form:

      {name:value}
    

    that that is easy to process as a JSON object on the client.

    e.g. Found on this page

     $.ajax({
       url: url,
       dataType: 'json',
       data: data,
       success: callback
     });
    

    Your callback function will then process the JSON and retrieve the value. As you can see from the link, you can use the getJSON() method as a shortcut.

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

Sidebar

Related Questions

I have a situation where I send jquery ajax post request but in my
I have an jquery ajax request that calls a PHP script that will send
I got this example demonstrating AJAX from Stoyan Stefanovs Object Oriented JavaScript at page
I have a jsp page. In the jsp page I do a ajax request
I am working on a project where I have to send an ajax request
I have 2 questions on this My code always seems to hit a 401
I have two questions: From personal experience, what free blog engine is the best
Here's what I'm hoping to do: I want to send an ajax request to
On one page i have list of questions with diffrent tipe of answers. (texboxes,
This question is closely related to Jquery - Send only some value from a

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.