在自定义 Joomla 组件中制作 JSON AJAX 响应 [英] Making JSON AJAX response in custom Joomla component

查看:23
本文介绍了在自定义 Joomla 组件中制作 JSON AJAX 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在我的 jQuery 前端和我的自定义 Joomla 组件之间进行 AJAX 通信.

I am been trying to make AJAX communication between my jQuery frontend and my custom Joomla component.

我的 JSON 响应已准备就绪,但问题是该组件改为打印 HTML 并在其中显示 JSON 代码.我不知道我做错了什么.

My JSON response is ready but the problem is that the component prints HTML instead and the JSON code is shown in it. I have no idea what I am doing wrong.

提前感谢您提供任何线索

Thanks in advance for any clues

推荐答案

确保在前端使用 GET 请求时,您已将 param: format=raw 附加到您的 URL 请求或 $.ajax({ data : 'format=raw', dataType: 'json' }),或者在发布您附加的表单时:

Make sure when using GET request in the frontend, you've attached param: format=raw to your URL request or $.ajax({ data : 'format=raw', dataType: 'json' }), or when posting a form you have attached:

<input type="hidden" name="format" value="raw"> 

这篇关于在自定义 Joomla 组件中制作 JSON AJAX 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆