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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:13:46+00:00 2026-05-24T03:13:46+00:00

I’m sure it is just a simple issue, I have looked in the forums

  • 0

I’m sure it is just a simple issue, I have looked in the forums but couldn’t find an example that was specific to my issue.

Basically I am displaying a table of hrefs, which each have an onclick() call to an ajax method, using a ‘get’ and a url.

function createRequestObject(){
var req;

if(window.XMLHttpRequest){
    //For Firefox, Safari, Opera
    req = new XMLHttpRequest();
    }
else if(window.ActiveXObject){
    //For IE 5+
    req = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
    //Error for an old browser
    alert("Your browser is not IE 5 or higher, or Firefox or Safari or Opera");
}
return req;
}


//Make the XMLHttpRequest Object
var http = createRequestObject();



function sendRequest(method, url){
if(method == "get" || method == "GET"){
    http.open(method,url,true);

    http.onreadystatechange = handleResponse;
    http.send(null);
}
}
function handleResponse(){
if(http.readyState == 4 && http.status == 200){
    var response = http.responseText;
    if(response){

        document.getElementById("DIVNAME").innerHTML = response;

    }
}
}

The call for an href looks like:

echo '<td><a href="#" onClick="sendRequest(\'get\', \''.$toPass.'\')"/>'.$variable.'</a></td>';

The $toPass variable is page.php?variable1='.$variable1.'&variable2='.$variable2.'&variable3=blah&action='.$option.'

When I pass a variable 1 for example : ‘TP111010114’ it works fine, the _REQUEST[‘variable1’]; grabs the variable and pushes it the through my sql request.

if the variable contains a # for example : ‘Blah #2’ the only piece of data that gets through is
Variable 1 = ‘Blah ‘ with the remaining variables being unassigned.
From what it looks like it is not getting anything after the #.
I tried encoding the url in php, then unescaping it in my ajax.js where you call window.open(‘get’, unescape(url), true); but I had the same result, it worked with any variable that didn’t contain #. When I tried to encode it using urlencode() and not decoding it in my ajax.js, the request was not going through.

The encoded request looks like:

page.php%3Fvariable1%3DTP111010114%26variable2%3D64%26variable3%3Dnew%26Action%3DOthers

if it is not encoded it looks like:

page.php?variable1=TP111010114&variable2=64&variable3=new&Action=Others

I used firebug to monitor the .js variables as they go through and it looks as though when I encode it that it should grab the proper variable, but it still only grabs before the # in the variable

http://www.randomsite.ca/page.php?variable1=WF225+Amendment+#2&variable2=543&variable3=new&Action=Others

Yet this request on the php side still gets $variable = $_REQUEST[‘variable1’]
$variable = ‘WF225 Amendment ‘, and the other variables are unnassigned.

It must be something to do with the way something is handling the #, but I do not see what I am missing here, if anyone could help it would be much appreciated.

I have renamed information for privacy purposes

  • 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-24T03:13:47+00:00Added an answer on May 24, 2026 at 3:13 am

    You need to urlencode the values you’re putting into the URL, not the whole URL including variable names. You want to encode the “blah #2” but not the “&variable1=” part. Ex:

    $toPass = 'page.php?variable1=' . urlencode($variable1) . '&variable2=' . urlencode($variable2) ...etc
    

    You won’t need any decoding on the HTML/JS end.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't

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.