Jump to content

Uri In Ajax Request

Recommended Posts

okay guys, hello how are you: I want to simply try using ajax in my codeigniter system. This is what I am trying to do, I ll write the example first:

function downloadText(url, callbackFunction){var XMLHttpRequestObject = false;if (window.XMLHttpRequest){XMLHttpRequestObject = new XMLHttpRequest();}else if (window.ActiveXObject){XMLHttpRequestObject = newActiveXObject("Microsoft.XMLHTTP");}if(XMLHttpRequestObject){XMLHttpRequestObject.open("GET", url);XMLHttpRequestObject.onreadystatechange = function(){if (XMLHttpRequestObject.readyState == 4 &&XMLHttpRequestObject.status == 200){callbackFunction(XMLHttpRequestObject.responseText);delete XMLHttpRequestObject;XMLHttpRequestObject = null;}}XMLHttpRequestObject.send(null);}}

I tried to run the event downloadText("<?php echo base_url()."my_controller/some_function"; ?>",alert); but seems like it alert nothing..? any method to run ajax request with this type of uri? btw, the actual uri is this:http://cms/index.php/my_controller/some_function". p/s: I echoed "test" in function some_function() Thx!!!

Edited by newrehmi
  • Like 1
Link to post
Share on other sites

why you need to calback alert() ? you can simply use it inside the function

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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