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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:14:56+00:00 2026-05-31T04:14:56+00:00

I am trying to send a simple URL request to a server with XML

  • 0

I am trying to send a simple URL request to a server with XML with something along the lines of

xmlhttp.open("GET","serverFile.php?q="+str,true);
xmlhttp.send();

I have three variables contained in the javascript file, i.e.:

var userName = Steve;
var findtype = Green Holder;
var findcategory = B Provincial;

I was of trying to “package” the strings together into somewhat

var combinedString = "find&userName=" + userName + "&type=" + findType + "&category=" + findCategory;

and then calling the function above

xmlhttp.open("GET","serverFile.php?q="+combinedString,true);

but I’m confused how to decode this on the server side or whether this would work at all. I was originally thinking of having an if statement:

$q=$_GET["q"];
if ($q == "find")
{
    $name=$_GET["userName"];
    $type=$_GET["type"];
    $category=$_GET["category"];
    ...do other coding here to get data
}

But I’m very new to PHP so I have no idea if this is the right approach. I was trying to figure out appropriate URL encoding online but is the combined string in the appropriate form? Would the “&” appropriately divide the contents or would I need & and would I need to place a plus sign between spaces or would it do that by itself? Any information would be helpful!

  • 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-31T04:14:57+00:00Added an answer on May 31, 2026 at 4:14 am

    You need to encode your URL components in JavaScript before you use string concatenation.

    combinedString = ... + encodeURIComponent(userName) + ... + encodeURIComponent(findType) + ...
    

    PHP will automatically fill $_GET with the url decoded values, so if you were to pass:

    ?foo=%2F%40%23%24
    

    PHP would automatically decode $_GET['foo'] to equal "/@#$"


    As for your & comment, you only ever need to escape XML when you’re using the value in XML (or HTML in this case, which is close but not quite identical).

    If you’re simply typing in the browser’s location bar, you’d use:

    somepage.php?foo=bar&fizz=buzz
    

    But if you were marking this up in an anchor element (<a>) you’d use:

    <a href="somepage.php?foo=bar&amp;fizz=buzz">lorem ipsum</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I'm trying to send a simple GET request using flex mx:HTTPService: <mx:HTTPService id=service
I am trying to send a simple NSURLConnection request: - (void) sendHTTPRequest:(NSString*)urlString { NSLog(@SendHTTPRequest:
I want to build simple camel application, which will get xml from URL and
I'm trying to send a GET request using HttpWebRequest. I've found a lot of
I am trying to send a simple get to another page, and it doesn't
I've been trying to send a JSON string to PHP server like this: $.ajax({
I am trying to do a simple ajax request to load in some XML
I have been trying to get a simple xhr request to work but for
I'm trying to send simple email via Ruby (no rails) on OS X, with
I'm trying to send messages generated by Google Protocol Buffer code via a simple

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.