CodeIgniter Forums
Calling php controlller script from javascript file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Calling php controlller script from javascript file (/showthread.php?tid=8012)

Pages: 1 2 3


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]Computerzworld[/eluser]
Hello. I am having one php controller named as event.php and one view file with the same name event.php. Now what I want to do is to call that controller file's function from my javascript but it calls view file instead of controller file. What should be the problem behind this? please help me. Thanks in advance.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]wiredesignz[/eluser]
Please provide more detail.

What function are you calling in the event controller?

Can you change the view file name and test again.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]Computerzworld[/eluser]
i even changed the name of view as event1.php but it calls the same file. Actually I want to get database's data into php using ajax. And I am using one javascript file for that.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]wiredesignz[/eluser]
Please provide more detail.

Which function are you calling in the event controller?

Please show some code, or even the URL you are using from Javascript.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]Computerzworld[/eluser]
for now i am printing simple value in that function.(just echoing hello in the function) i just want to call this function from my javascript file....


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]Computerzworld[/eluser]
Actually i want to call one controller function say GetData() in my javascript file i want to know how i can call controller function in my javascript file i think now it is clear what i want to say?

Thanks for advance


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]wiredesignz[/eluser]
I'm sorry, it's impossible to help without viewing your javascript or controller code.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]Computerzworld[/eluser]
ok Please tell me is it possible to call controller class function form any javascript file if possible than how can we call that function in javascript .Sorry for disturbing

Thanks in advance.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]wiredesignz[/eluser]
Yes it is possible, the javascript must create and submit a URL to the server in the same fashion as a browser might.


Calling php controlller script from javascript file - El Forum - 05-01-2008

[eluser]nfx-nano[/eluser]
Yes it's possible, just direct to or include the proper url, www.somesite.com/controller/function

You say it calls the view file but that's not how it works. The router directs to the controller function first and the function then calls the view file. I don't know how you would call this from your javascript file, depends on which js library you are using.