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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:23:34+00:00 2026-06-14T09:23:34+00:00

I have a php file (myxml.php) that uses a 3rd-party API to return XML.

  • 0

I have a php file (myxml.php) that uses a 3rd-party API to return XML. It echoes the XML on the last line.

 $xml = file_get_contents($url);
 echo $xml;

Another php file (index.php) uses jQuery to read this XML in:

$(document).ready(function(){
        $.ajax({
            type: "GET",
            url: "myxml.php",
            dataType: "xml",
            success: function(xml) {

My index.php file needs to pass the myxml.php file a variable called ‘searchitem’ that it can use before calling the API.

How do I pass $searchitem to myxml.php ?

Also, for better performance, can I import the php variable $xml to my ajax code above without the need to echo it?

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-14T09:23:35+00:00Added an answer on June 14, 2026 at 9:23 am

    You apparently are using jQuery.

    Just add it to the url (so build the jQuery syntax with php)

        $.ajax({
            type: "GET",
            url: "myxml.php?searchitem=<?php echo $searchitem; ?>",
            dataType: "xml",
            success: function(xml) {
    

    In turn, on myxml.php you can get this with the $_GET variable.

    $searchitem = $_GET['searchitem'];
    

    Without echo? Only possible if you don’t need ajax, so you can just include the myxml.php file into the index.php file. But I assume there is a good reason for doing ajax

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

Sidebar

Related Questions

I have a php script that reads an XML file and modifies it with
I have a PHP file that contains a large array (about 90KB). I'm considering
I have a php file setup to pull through ONE XML data feed, What
I have a PHP file which will return something like <div id=title>Add Us On
I have an XML file with data stored like this: <myxml> <item name=column18>88744544</item> <item
I am trying to auto increment my xml file. I have a form that
I have created a XML file using PHP's simple XML, saved the file. When
I have been using PHP's simple XML function to work with an XML file.
i have an xml file (scores.xml) which im using a php codes to add
I have the following script that recieves an xml file and reads it with

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.