Welcome Guest, Not a member yet? Register   Sign In
jquery load in CI, how?
#1

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

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

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




Theme © iAndrew 2016 - Forum software by © MyBB