0

I have tried to acces it through an ajax call and by simply going to it by url, It always give me a 404

i have flushed my caches multiple times and even tried to remove and re-add the module (as i have had the problem with other modules and read on other responses on the problem)

i also have looked it up on internet, but i can't seem to find any solution
(module name : TTK_rest)

.module:

function TTK_rest_menu() {  
    $items = array();
    $items['TTK_rest_api/TTK_task_progression'] = array(
        'page callback' => 'TTK_task_progression_view',
        'access arguments' => array('access content'),
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function TTK_task_progression_view(){

    return '{"pom":"pom"}';
}

and the ajax call to it:

$.ajax({                 
                url:'/TTK_rest_api/TTK_task_progression',                   
                data: {"getProgress": "true"},//, "event_id":settings['TTK_task_progression']['jsEvent_id']
                type: "POST",
                contentType: "JSON",
                success: function(data){
                    var $data = $(data);
                    console.log(data);




                },
                error: function(err){
                    console.log("neupe, try again");
                }
            });
PudiPudi
  • 38
  • 8

1 Answers1

0

finally found the solution (posted the question after multiple hours of searching, if i've known i would have find an answer this quick i wouldn't have asked it.. still going to leave it up with a response in case there is someone with the same problem

solution to the problem was that i had to have my function name had to have the module name prefix

note: i have an other module called 'TTK_task_progression', might be the origin of the problem i had

solution:

function TTK_rest_menu() {  
    $items = array();
    $items['TTK_rest_api/TTK_task_progression'] = array(
        'page callback' => 'TTK_rest_progression', // <- changed
        'access arguments' => array('access content'),
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function TTK_rest_progression(){ // <- changed

    return '{"pom":"pom"}';
}
PudiPudi
  • 38
  • 8
  • That isn't what fixed it, the function name is arbitrary (so long as its unique). More likely you didn't clear the cache – Clive Mar 30 '16 at 12:26
  • as i said, if you had taken the time to read the post, i have flushed my cash multiple times and even tried to delete and recopy the whole module, both of these did not fix my problem. – PudiPudi Mar 31 '16 at 07:48
  • Maybe I missed it because you spelled it wrong. Either way, this answer didn't fix the issue in the question, unless you have a non-standard version of core – Clive Mar 31 '16 at 08:02
  • i also do have a second module which is called TTK_task_progression, could it be possible they were in conflict because of the same prefix? – PudiPudi Mar 31 '16 at 09:15
  • deleted my previous comment because it was unreadable (forgot comments had no new lines):: Maybe english isn't my primary language? And maybe do typo's can happen? Either way this fixed it for me, it was the only thing i changed and it worked. As far as i now i do run standard core (version 7.42). The only reason i continue to respond is so maybe if someone has another solution maybe he/she will be willing to post it. Simply saying that the answer "doen't" work, isn't helping anybody. – PudiPudi Mar 31 '16 at 10:03