帮助新手。勾勒出示例代码,在Ajax请求之后我无法使seflink正常工作。
ajax请求代码:
var timer_search = 300;
var max_symbols = 1;
jQuery("#jshop_search").bind("change paste keyup", function() {
var count_symbols = jQuery(this).val();
var count_search = jQuery(this).val().length;
if(count_search >= max_symbols) {
go_search(count_symbols, count_search);
}
});
function go_search(count_symbols, count_search) {
var request;
request = jQuery.ajax({
type:'post',
url:'/components/com_jshopping/controllers/ajax_search.php',
data:{check: count_symbols},
success: function(data){
jQuery('#results').html(data);
}
});
}
ajax_search.php代码:
(isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') or die;
define('_JEXEC', 1) or die();
define('JPATH_BASE', dirname(dirname(dirname(dirname(__FILE__)))));
define('DS', DIRECTORY_SEPARATOR);
$path = JPATH_BASE . DS . 'includes' . DS;
require($path . 'defines.php');
require($path . 'framework.php');
if (!file_exists(JPATH_SITE.'/components/com_jshopping/jshopping.php')){
JError::raiseError(500,"Please install component \"joomshopping\"");
}
require_once (JPATH_SITE.'/components/com_jshopping/lib/factory.php');
require_once (JPATH_SITE.'/components/com_jshopping/lib/jtableauto.php');
require_once (JPATH_SITE.'/components/com_jshopping/tables/config.php');
require_once (JPATH_SITE.'/components/com_jshopping/lib/functions.php');
$app = JFactory::getApplication('site');
$app->initialise();
jimport('joomla.application.component.controller');
$jshopConfig = JSFactory::getConfig();
$db = JFactory::getDbo();
$lang = "name_ru-RU";
$search_array = explode(" ", $_POST['check']);
foreach($search_array as $search_sql) {
$sql = $sql."%".$search_sql."%";
}
$limit = 10;
$sql_get = "SELECT DISTINCT(category_id)
FROM #__jshopping_products_to_categories";
$db->setQuery($sql_get);
$result_get = $db->loadRowList();
foreach ($result_get as $result) {
$results_cat = $results_cat.$result[0].",";
}
$results_cat = trim($results_cat, ',');
$sql_get = "SELECT category_id, `".$lang."` FROM #__jshopping_categories
WHERE category_id IN (".$results_cat.") AND category_publish='1' AND
`".$lang."` LIKE \"$sql\" ORDER BY `".$lang."` ASC LIMIT 10";
$db->setQuery($sql_get);
$result_get = $db->loadRowList();
foreach($result_get as $category)
{
if($limit > 0) {?>
<a href='<?php print SEFLink('/index.php?
option=com_jshopping&controller=category&task=view&category_id='
.$category[0].'', 1); ?>'><?php print $category[1]."<br>"; ?></a>
<?php
$limit--;
} else {
break;
}
}
获取链接(index.php?option = com_jshopping&amp; controller = category&amp; task = view&amp; category_id = 125&amp; Itemid = 121)
请帮助:)