Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Send ajax request and handle function
  • Hello, I have little problem with ajax request. $(function() {
    $("#sort").sortable({ opacity: 0.6, cursor: 'move', update: function() {
    var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
    $.post("uprav", order, function(theResponse){
    $("#contentRight").html(theResponse);
    });
    }
    });
    });
    I created drag and drop script with JqueryUI and I call php function uprav.
    In site controller I created function:
    public function action_uprav()
    {
    echo "ahoj";
    } It works, the function is called, but it want to rander the all view again. And show me this error: Notice! ErrorException [ Notice ]: Undefined variable: content APPPATH/views/template.php @ line 195: 194: <div class="span16">
    195: <?php echo $content; ?>
    196: </div>
    I want only to call function witch only return data, I don want rander the view again.
    Can you help me ? ... Sorry for my english
  • For ajax calls, use a controller that extends Controller_Rest. It returns only data in your choice of format (xml, json, etc).
  • Thanks, and how Can I call this uprav function in thi controller ?
    My position when I call ajax is: [url=http://localhost/phpframework/public/index.php/site/]http://localhost/phpframework/public/index.php/site/[/url] Ajax :
    $.post("ajax/uprav", order, function(theResponse).... Calling "ajax/uprav" don´t work, because it create this url: public/index.php/site/ajax/uprav but i need create this url without "site": public/index.php/ajax/uprav How Can I do it ?
  • You need to request the full URL. Normally, your rewrite rules will remove the public/index.php part from your URL, and you can just call '/ajax/uprav'. You can try using Uri::create() to generate the URL, it should create the correct URL for you.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion