Welcome Guest, Not a member yet? Register   Sign In
JQuery / load event
#1

[eluser]blitzneo[/eluser]
I'm trying to load a template, based on a select box using JQuery. It is tested and working without using CI, but if include this javascript inside CI, it shows no error, but it doesn't work.

This is what the code looks like:

$(document).ready(function() {

$("select").change(function(){

$("#box").load('template.php');
});
});

Am I missing some important configuration ? Shall I add complete url to the template file ? I don't really understand this issue..

Thanks =)

**Edit: sorry.. I just realized this wasn't the right thread to post.. cannot delete this and move it :/
#2

[eluser]InsiteFX[/eluser]
You need to look into also CSRF!
Yes you would need the full path.

place this in your html head section, then you can use the baseUrl any where's in your js code.
Code:
// Replace $ in script tags with s !
<$cript>
    var baseUrl = &lt;?php echo base_url(); ?&gt;;
</$cript>

// change this in your js code.
$("#box").load(baseUrl+'template.php');

InsiteFX
#3

[eluser]blitzneo[/eluser]
HI, thanks for the tip, I did that changes already, and tried to alert(baseUrl) but no response.. guess I have to activate something else in the config file or, this trick is not working for me =)

Keep trying though!

**Edit:
Has to be like this var baseUrl = "&lt;?php echo base_url(); ?&gt;";.
But the loading part, still not working =P

$("#box").load(baseUrl + 'template.php');

**Edit:
I can get the "index.php" by doing $("#box").load(baseUrl); but no other page in the views folder, so I think I must try something with the controller
#4

[eluser]blitzneo[/eluser]
Done Big Grin
Thanks a lot for the first tip, always the first step is the hardest one.
If anyone needs to load a file this way, you need to call it through the controller (maybe I should know this before..).

謝謝!
#5

[eluser]InsiteFX[/eluser]
Sorry about that I copied it real quick, and grabed in between the qoutes.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB