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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.