Welcome Guest, Not a member yet? Register   Sign In
How to refer some files in CI from javascript
#1

[eluser]Navas[/eluser]
Hi i was referring to a project in php using jquery ! which i was trying to use it in my CI project. But i was struck inside one javascript which makes use of a php file named processor.php inside a directory and from that all process took place referring other class.

This function is located in global.js which used the jquery classes along with it.
Code:
function update_priority(drugli, newpri){
    id_split = drugli.split('_');
    id = id_split[1];    
    
    $.post("classes/processor.php",{
        priority: newpri,
        id: id
    });
    //alert("id:"+id+" pri:"+newpri);
}

Can anyone help me how to convert the "classes/processor.php" in to CI compatible one where that php file needs to be added..

Any suggestions will be helpful.
#2

[eluser]xwero[/eluser]
add a new method to the controller that is closest in functionality or keep you ajax calls together in an ajax controller and copy the content of processor.php
#3

[eluser]Navas[/eluser]
[quote author="xwero" date="1194722195"]add a new method to the controller that is closest in functionality or keep you ajax calls together in an ajax controller and copy the content of processor.php[/quote]

Hi,
Thanks for ur suggestions.But can u explain me how i could make a call of the codeIgniter controller function in the place of classes/processor.php
Code:
$.post("classes/processor.php",{
        priority: newpri,
        id: id
    });
#4

[eluser]xwero[/eluser]
lets say you put your code in a controller named ajax and the method is called update_priority. You can call it
Code:
$.post("ajax/update_priority",{
        priority: newpri,
        id: id
    });
#5

[eluser]Navas[/eluser]
[quote author="xwero" date="1194875832"]lets say you put your code in a controller named ajax and the method is called update_priority. You can call it
Code:
$.post("ajax/update_priority",{
        priority: newpri,
        id: id
    });
[/quote]


I did tried that but im not getting success that method is not getting invoked..
#6

[eluser]xwero[/eluser]
try
Code:
$.post("/index.php/ajax/update_priority",{
        priority: newpri,
        id: id},
        function (data, textStatus) {
  alert('test');
});

Sometimes you have to search a bit for the right relative url depending on your configuration.
If you have firebug you can check the url when it's send.
#7

[eluser]Navas[/eluser]
Thanks for ur timely help i got it work by providing an absolute url.




Theme © iAndrew 2016 - Forum software by © MyBB