First, let me say that I've looked through other similar questions on this site and the jQuery documentation. So far, I haven't found something that fixes my issue.
首先,我想说我已经浏览了本网站上的其他类似问题和jQuery文档。到目前为止,我还没有找到解决问题的方法。
I am trying to get HTML data from ajax request but every time in response i got current page html.
我试图从ajax请求获取HTML数据,但每次响应我得到当前页面的HTML。
Here is my Ajax function.
这是我的Ajax功能。
jQuery.ajax({
url:"url to function call",
type: "POST",
datatype : "html",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {
qtext: filter_search
},
success:function(data) {
console.log(data);
jQuery("#appendHtml").html(data);
},
error : function(data) {}
});
and here is my Joomla PHP function where I have return HTML
这是我的Joomla PHP函数,我返回HTML
public function getHtmlAjax()
{
$token = $this->createToken();
$listData = $this->getKapsulelist($token);
$html = $this->buildLayout($listData);
echo $html;
jexit();
}
1 个解决方案
#1
0
I faced the same issue, and I solved it by putting die;
at the end of the ajax page.
我遇到了同样的问题,我通过放弃来解决它;在ajax页面的末尾。
(On the page that is passed in the url tag of the ajax function, i.e. at the end of the function call url OR in in simple words the page on the page to which request is sent).
(在ajax函数的url标记中传递的页面上,即在函数调用url的末尾,或者简单地说是发送请求的页面上的页面)。
#1
0
I faced the same issue, and I solved it by putting die;
at the end of the ajax page.
我遇到了同样的问题,我通过放弃来解决它;在ajax页面的末尾。
(On the page that is passed in the url tag of the ajax function, i.e. at the end of the function call url OR in in simple words the page on the page to which request is sent).
(在ajax函数的url标记中传递的页面上,即在函数调用url的末尾,或者简单地说是发送请求的页面上的页面)。