singlepage ajax request give back error

Permalink
Hello everybody,

i try to get a ajax request from a single page! but only an error occures.
the firefox netzanalysis shows as answer the full html document.

controller method:
public function action_get_fieldtyp_request(){
        $result = "request said yes "; 
        echo json_encode(array("result" => $result));
        exit;
    }


Ajax request (SinglePage)
$.ajax({
        type : 'post',
        url : "<?php $this->action("get_fieldtyp_request"); ?>",
        dataType: 'json',
        success : function(rs){
            console.log('success');
        },
        error : function(){
            console.log("error");
        }
   });


i dont know where is the problem!
sry for the bad english.

 
priteshmahajan replied on at Permalink Reply
No need to add action prefix on controller function like

function action_get_fieldtyp_request (){
 $result = "request said yes "; 
        echo json_encode(array("result" => $result));
        exit;
}
Replace to 
function get_fieldtyp_request(){
 $result = "request said yes "; 
        echo json_encode(array("result" => $result));
        exit;
}


It will definitely work.
bexsta replied on at Permalink Reply
the same problem, the request give back a error
bexsta replied on at Permalink Reply
the problem was the missing "echo" in the ajax url :/ :/ :/