CodeIgniter Forums
jquery load in CI, how? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: jquery load in CI, how? (/showthread.php?tid=20791)



jquery load in CI, how? - El Forum - 07-21-2009

[eluser]searain[/eluser]
Code:
<html>
    <head>
        <title>AJAX with jQuery Example</title>
        [removed][removed]
        <style type="text/css">
        #wrapper {
            width: 240px;
            height: 80px;
            margin: auto;
            padding: 10px;
            margin-top: 10px;
            border: 1px solid black;
            text-align: center;
        }
        </style>
    </head>
    <body>
        <div id="wrapper">
        [removed]
        $(document).ready(function(){
            $("#generate").click(function(){
                $("#quote p").load("script.php");
            });
        });
        [removed]
        &lt;input type="submit" id="generate" value="Generate!"&gt;&lt;br />
        <div id="quote"><p></p></div>
        </div>
    &lt;/body&gt;
&lt;/html&gt;

$("#quote p").load("script.php");


In traditional php, if I put the script.php in the same folder as this html document, then it is working.

In CI, more like this will be part of the view page. Then in the view page, how can I call the server side php script? like
$("#quote p").load("script.php");


Where I put the server side php script, same as function of a controlloer?


jquery load in CI, how? - El Forum - 07-21-2009

[eluser]Thorpe Obazee[/eluser]
[quote author="blackhorse66" date="1248243293"]
Code:
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;AJAX with jQuery Example&lt;/title&gt;
        [removed][removed]
        &lt;style type="text/css"&gt;
        #wrapper {
            width: 240px;
            height: 80px;
            margin: auto;
            padding: 10px;
            margin-top: 10px;
            border: 1px solid black;
            text-align: center;
        }
        &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <div id="wrapper">
        [removed]
        $(document).ready(function(){
            $("#generate").click(function(){
                $("#quote p").load("script.php");
            });
        });
        [removed]
        &lt;input type="submit" id="generate" value="Generate!"&gt;&lt;br />
        <div id="quote"><p></p></div>
        </div>
    &lt;/body&gt;
&lt;/html&gt;

$("#quote p").load("script.php");


In traditional php, if I put the script.php in the same folder as this html document, then it is working.

In CI, more like this will be part of the view page. Then in the view page, how can I call the server side php script? like
$("#quote p").load("script.php");


Where I put the server side php script, same as function of a controlloer?[/quote]


Perhaps you can use the full path to the script?
Code:
http://yoursite.com/script.php



jquery load in CI, how? - El Forum - 07-28-2009

[eluser]searain[/eluser]
Found it!

Jquery load etc. the client site src page should be just like other php pages on the site. Set it up as function of a controller.