• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI & ajax

#1
[eluser]nuttynibbles[/eluser]
hi, i need to use ajax with CI. i need to pass in character like ??,& @ : = etc..
but i received an error saying "The URI you submitted has disallowed characters."
I understand this has to do with the config. but my question is, is there another around it? will it be safe to include these characters in my config file. would this lead to security breach?? tks

here is my ajax engine code:
Code:
var xmlHttp

function ajaxpost(siteurl,param,tag)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request");
        return;
    }
    var strurl=siteurl;
    strurl=strurl+"/"+param;
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
            document.getElementById(tag)[removed]=xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",strurl,true);
    xmlHttp.send(null);
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try{
     // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
     }
    catch (e){
     // Internet Explorer
     try{
         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
     }
     catch (e){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
    }
    return xmlHttp;
}

html code:
Code:
<div>&lt;input type="submit" value="submit"&gt;&lt;div>
<div id="display"></div>
okay there's suppose to be onclick=ajaxpost('controller/function','hello world???://','display') in the submit button but i cant seems to add over there.. strange

#2
[eluser]nuttynibbles[/eluser]
anyone with suggestions? what are the usual way to work with CI and ajax if passing in parameters like ?://*&

#3
[eluser]Hannes Nevalainen[/eluser]
Send the data via POST instead, then you won't have the trouble!
//Hannes!

#4
[eluser]nuttynibbles[/eluser]
hey hannes, tks alot. i manage to do it!!

#5
[eluser]Hannes Nevalainen[/eluser]
No problemo.

Happy Coding!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.