Welcome Guest, Not a member yet? Register   Sign In
CI and javascript
#1

[eluser]halwaraj[/eluser]
I have a piece of javascript code.

I have it in two view PHPs. Now, the issue is that the first view behaves as expected however, the second one behaves differently.

The only difference in code is that the control goes to first view from index function in controller while the control goes to second view from other function.

The flow is

index() in controller.php -> first_view.php(that has some javascript code)->A page is shown. Click a link on the page -> second() in controller.php -> second_view.php(that has some javascript code) -> should show the same page.

This does'nt happen.

INTERESTING THIS:

If I send the controll to second_view.php from index() in controller.php the JS works as expected.

Does it have something to do with URL?

Also I import the JS, css and images as follows:
Code:
[script type="text/javascript" src="js/tomato.js"][/script]

instead of

Code:
[script type="text/javascript" src="[?php base_url()?]./js/tomato.js"][/script]

Replaced square brackets for angular brackets

Which one is the correct way?
#2

[eluser]umefarooq[/eluser]
hi just do this only

Code:
[script type="text/javascript" src="[?php echo base_url()?].js/tomato.js"][/script]

you have to echo base_url() and also remove / befor js and it will work fine




Theme © iAndrew 2016 - Forum software by © MyBB