CodeIgniter Forums
Space problem in Java script - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Space problem in Java script (/showthread.php?tid=48851)



Space problem in Java script - El Forum - 01-30-2012

[eluser]Shiju S S[/eluser]
I have a javascript district.js
Code:
var xmlHttp55;

//////////////////////////
function districtcheck(id){
document.getElementById("cityspace")[removed]="<img src='images/loading.gif' width='10' height='10' > Loading.......";  
xmlHttp55=GetXmlHttpObject()
if (xmlHttp55==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  
var url="/quickbharath/addfields/district"
url=url+"/"+id;    

xmlHttp55.onreadystatechange=stateChangedEff1;
xmlHttp55.open("GET",url,true);
xmlHttp55.send(null);
}
function stateChangedEff1()
{
if (xmlHttp55.readyState==4)
document.getElementById("cityspace")[removed]=xmlHttp55.responseText;
}
///////////////////
function GetXmlHttpObject()
{
var xmlHttp55=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp55=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp55=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp55=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp55;
}
It passes id to the controller "/quickbharath/addfields/district"

When I echo id
The value 'Tamil Nadu' is seen as 'Tamil%2Nadu'

How can I solve the space problem. Please help me.


Space problem in Java script - El Forum - 01-30-2012

[eluser]CroNiX[/eluser]
A space is not a valid URL character, so it was urlencoded(). Now you need to decode it.