ajax - Replace content of a div with an external php file in Laravel 3 -


i have unordered list of movies being displayed rotten tomatoes api in page called browse (using laravel framework). trying use ajax load content div separate file have setup route called movie when user clicks on anchor.

in routes file have this: route::get('browse', array('as'=>'browse', 'uses'=>'browse@index')); route::get('movie', array('as'=>'movie', 'uses'=>'browse@movie'));

browse view located @ /application/views/browse/index.blade.php

$movies = $search_results->movies; echo '<div id="browse">'; echo '<ul class="movieresults">';   foreach ($movies $movie) {     echo '<div class="moviecard">';      echo '<li><img src="'. $movie->posters->detailed .'"</li>';     echo '<li class="moviecardinfo"><a href="movie" class="movie">' . $movie->title . '</a></li>'; // here's have problem     echo '</div>';   } echo '</ul>'; echo '</div>'; 

movie view located @ /application/views/browse/movie.blade.php. have dummy text now

echo '<div class="details">'; 

echo '

test

'; echo '';

browse controller

public $restful = true;   public function get_index()    {     return view::make('browse.index')     ->with('title', 'browse movies');   } } 

javascript file $(function() { $('.movie').click(function() { $('.details').load(this.href); return false; }); });

the project can found here

seems using wrong "this"-operator. should "$(this)" if it's jquery scripts? (the javascript part...)

also: ur telling add result ".load()" ".details", can't see have such field in html code?

edit

change following in /application/views/browse/index.blade.php:

echo '<li class="moviecardinfo"><a href="movie" class="movie">' . $movie->title . '</a></li>';  echo '<li class="moviecardinfo"><a href="movie" class="movie">' . $movie->title . '</a><div class="details"></div></li>'; 

and remove "div.details" response, response returns text want in details.

then, in the javascript:

$(function() {      $('.movie').click(function() {         $('.details').load($(this).href);         return false;     }); }); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -