Welcome Guest, Not a member yet? Register   Sign In
Calling php controlller script from javascript file
#1

[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.
#2

[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.
#3

[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.
#4

[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.
#5

[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....
#6

[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
#7

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

[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.
#9

[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.
#10

[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.




Theme © iAndrew 2016 - Forum software by © MyBB