CodeIgniter AJAX error returning the same page

when I try to make an AJAX request with jQuery as an answer, I get the html of the same page! here is a live preview (editing is not available due to the fact that I am fixing it)

here are my files Edit: I made changes to some files

main controller:

Class Main extends Controller {

function Main() 
{
      parent::Controller();   
}

function index(){

    $this->load->view('oxila_index');
}}

View Oxila_index (only the rest of the JS html is in the link above)

 <script type="text/javascript">
        $(document).ready(function(){
            $("#inv").hide();
        });
        $(document).ready(function(){
            $("#submit").click(function(evt){

                $.post("/ajax/process", {
                    url: $("#url").val()
                }, function(response){
                        $("#output").html("");
                    $("#inv").show("slow"); 
                        $("#output").html(response);
                }, "text");
                evt.preventDefault();
            }); 
        });
    </script>

Ajax controller

Class Ajax extends Controller {

    function process(){

        $data['url'] = $this->input->post('url');
        $this->load->view('test',$data);
        echo "hello world";
    }
}
+5
source share
5 answers

This is what the man on the forums told me

you definitely have something in place. Every single path I entered after the url took me to the house page

URL- - . ( config/config.php)

"REQUEST_URI", !

+1

, . FYI, google chrome Linux.

. script <head> , </body>. , js- , css .

-, , GET POST. IE, , .

-, $("#output").html(""); . $("#output").html(response);, .html() . .

+1

,

0

, FALSE;

$config['compress_output'] = FALSE;
0

?

public function test(){

    echo $this->input->post('lurl');

    }

- : http://codeigniter.com/user_guide/general/controllers.html

URL- javascript, , :

$.post("http://yourwebsite/oxila/test/")
0

All Articles