AnsweredAssumed Answered

Why is my ajax action view treated as an action view instead?

Question asked by Rodolfo Tuble on Aug 10, 2016

I followed this guide to create my ajax return: Link here, But the problem is that it is treated as a normal action view "by normal I mean that when I open the URL directly it displays a page which shouldn't be happening since this is an AJAX view and should instead display a white page". 

 

How did I create this? Steps are as follow:

1. I created a custom controller in my module that calls the action:

Location: custom/modules/Users/

class CustomUsersController extends UsersController
{

 

function get_checkpaymentemail(){
$this->view = 'customCheckPaymentEmail';
}
}

 

2. I created the view file as stated in the link:

Location: module/Users/views/

view.customCheckPaymentEmail.php

 

p.s even if I add some text here to be displayed when I directly access this page using the action stated for it the text is not displayed at all it's like it's calling a different file.

 

 

3. create the connection at action_view_map.php

$action_view_map['getcheckpaymentemail'] = 'customCheckPaymentEmail';

 

4. Finally call the ajax view in your js file

$.ajax({
method: "POST",
url: "index.php?module=Users&action=getcheckpaymentemail",
data: {check_flag: "2"},
success: function (data) {
tem_data = data;
console.log(tem_data);
}
});

 

So is there anything missing with my steps that causes this problem? This is really weird and I don't know why this is happening.

Outcomes