我爲這個組件創建了一個joomla.in組件我想向用戶顯示一個表單並獲取用戶名並通過ajax.i將她的名字發送到服務器這個代碼用於從default.php文件中獲取用戶的數據。如何在joomla中使用jQuery.post()
<?php
defined('_JEXEC') or die('Restricted access');?>
<div id="results"></div>
<input type="text" name="name" id="name" value="">
<input type="button" class="button" id="savename" value="Save Name">
<?php
$document = JFactory::getDocument();
JHtml::_('jquery.framework');
?>
<script>
jQuery(document).ready(function(){
jQuery("#savename").click(function(){
var name = jQuery('#name').val();
jQuery.post("/components/contactf/ajax.php?name="+name , function(response){
jQuery('#results').html(jQuery(response).fadeIn('slow'));
});
});
});
</script>
我在「contactf」 .jquery.post組件名稱()不能調用ajax.php file.I認爲問題是 "/components/contactf/ajax.php?name="+name
。我不知道如何設置參數爲jQuery.post()
正常。我需要使用JPATH_BASE
??
'JHTML :: _( 'jquery.framework');'= 3的Joomla,所以你不應該使用'JRequest';) – Lodder
@Lodder我excatly像這樣使用,但不工作:( –
ajax alert返回html頁面的源碼 –