Resources have universal interface to call Xajax. It is very simple. Example with Field plugin. In your plugin output add JavaScript code.
function onRenderField(&$obj, &$params, $type) { if($type != 'myfieldname') return; echo '<div id="id_100"></div>'; echo '<a href="javascript:void(0);"'; echo 'onclick="'; echo "xajax_jsCallPlugin('joomsuite_content_fields', 'myfieldname', 'xajax_sayHello', [100, 'Hello']);"; echo '">'; echo JText::_('Click Here').'</a>'; }
It is not hte best coding. I devided string to few echo's because of GEHSI format. YOu can echo it as one string;
xajax_jsCallPlugi parameters
- joomsuite_content_fields -Group where is the plugin with Ajax function
- myfieldname - Name of the plugin. It is value of "element" field in #__plugins table
- xajax_sayHello - Name of the function in that plugin. Important that in the name word xajax should present.
- [100, 'Hello'] - Array of values.
Then in the same plugin you create function.
function xajax_sayHello( &$objResponse, $id, $word ) { $objResponse->script('alert("I am Here");'); $objResponse->assign("id_{$id}", 'innerHTML', $word); $objResponse->setReturnValue( 1 ); }
Note that first parameters in this function is always $objResponse. You do not need to return it just call its functions. Then you add as many parameters as mane you place in last parameter of xajax_jsCallPlugin inside [ ]

+1 (209) 800 1209