Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Url for ajax using JQuery (solved)

Hi, I am new to Phalcon and php framework in general. I am having problem building url for calling controller/action through JQuery.

I have a PageController which looks like this:

class PageController extends Phalcon\Mvc\Controller{

  public function indexAction($id){
    if($id)
      echo $id;
  }

  public function showAction(){    
  }
}

With index.phtml

<?php
// index.phtml
echo $this->getContent();
?>
<a id="support" href="#">click here</a>
<div class="extend"></div>

and show.phtml

<?php
//show.phtml
echo $this->getContent();
?>
<p> this is show page </p>

and the jquery:
$(document).ready(function(){
  $('#support').click(function(e){
    e.preventDefault();
    $('.extend').load('http://localhost/page/show');
  });
});

Yes, it's a simple script. The javascript and JQuery are in different files My current position is in 'http://localhost/page/index' I am trying to load up 'page/show' inside the 'extend' class div in index.phtml file.

The problem I am having is the url inside JQuery.load function. Here's what I've tried so far: $('.extend').load('http://localhost/page/show'); $('.extend').load('<?php echo $this->url->get('page/show'); >?'); $('.extend').load('page/show'); And none of them works. The number 3 works but it's more like the 'page/show' just becomes parameter for indexAction.

Am I missing something here. thanks



1.3k
Accepted
answer

Sorry about that seems I got it resolved. forgot to put a comment on the code '$this->view->disabled();

Also, just a heads up that you can use this syntax highlighting as explained here: http://forum.phalconphp.com/discussion/1/welcome-to-the-forum