Jump to content

How to best send + symbol?


mctrivia

Recommended Posts

function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MakeRequest()  //$request1,$request2,...,$callback=null
{
  $request="av0=" + escape(arguments[0]);
  var xmlHttp = getXMLHttp();
  if (arguments.length > 1) {
    for ($i=1;$i<arguments.length-1;$i++) {
      $request=$request + "&av" + $i + "=" + escape(arguments[$i]);
    }
    if (arguments[arguments.length-1]==null) {
      xmlHttp.onreadystatechange = function () {};
    } else {
      eval("xmlHttp.onreadystatechange = " + "function () { if (xmlHttp.readyState == 4) {" + arguments[arguments.length-1] + "(xmlHttp.responseText);}};");
    }
  } else {
    xmlHttp.onreadystatechange = function () {};
  }
  xmlHttp.open("POST", "ajax", true);
  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");         
  xmlHttp.send($request);
}

 

The previous code is my AJAX script.  I wrote it myself as a way to understand how it works and to deal with my sites strange structure.  It works except when I pass a value to it with a + symbol the php sees this as a space probably because i use escape(arguments[$i]) to deal with the issue of some other special characters being in the input.  Any ideas how to fix the script or process results in php so all characters can be passe?

Link to comment
https://forums.phpfreaks.com/topic/227837-how-to-best-send-symbol/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.