I have a form that is a drop down select list.
I also have an action, that looks for the request parameter:
indexAction:
if($this->getRequest()->isXmlHttpRequest())
{
$this->setLayout('layout');
}
$param = $this->getRequestParameter('type');
if($param == 'video')
{
isicsBreadcrumbs::getInstance()->addItem('All Videos', '@homepage');
$pager = new sfPropelPager('Item', 15);
$pager->setPage($request->getParameter('page', 1));
$pager->setPeerMethod('doSelectLatestVideo');
$pager->init();
$this->pager = $pager;
}
elseif($param == 'photo')
{
isicsBreadcrumbs::getInstance()->addItem('All Photos', '@homepage');
$pager = new sfPropelPager('Item', 15);
$pager->setPage($request->getParameter('page', 1));
$pager->setPeerMethod('doSelectLatestPhoto');
$pager->init();
$this->pager = $pager;
}
}
Now this works fine when the url is: example.com?type=video - it load开发者_JAVA百科s the video content
The problem is, I'm wanting to update the content using AJAX and because I'm doing it via AJAX, I'm struggling to get the requestParamater, since it is no longer in mu URL;
ajax function:
$("#filter-form-newsroom .submit").live('click', function(e){
$("#search-results").html(ajax_loading);
var content_type = $("#filter-form-newsroom #type").val();
$.ajax(
{
url: "",
type: "GET",
data: "?type=" + content_type,
success: function(data){
var $response=$(data);
var filtered_response = $response.find('.post');
$("#search-results").html(filtered_response).hide().fadeIn("fast");
}
});
e.preventDefault();
});
This function checks the parameter in my select list and is supposed to filter by the requestParamter, but it isn't working.
Any ideas?
Thanks
Rather than putting ?type=" into the data
property, put it in the url
. Wouldn't that result in the same request you get when you type the URL yourself?
精彩评论