This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Hi there

I am developing a plugin which uses a lot of ajax calls from the ui. When the user clicks something within my plugin calls are made to onXXX() functions in my component.

I am often wanting to return pure HTML/text back from these ajax requests and render the content in divs. However any content i return from the onXXXX() AJAX call back to the client is wrapped in json as { "result": "HTML content" };

I can modify my ajax requests to decode the json, but i was wondering if there was a way in october to indicate that data returned from a plugin is just raw text which can be passed back to the client.

I could also just echo the content within the Ajax function and then die, but i dont think thats probably the best way.

Also i think i should say that i am making the calls to the component manually from my own js included using AddJs. I make these calls directly by setting :- X-OCTOBER-REQUEST-HANDLER': 'ReporticoAdmin::onAjax in the header in order to get it routed through october. im not using any partials

Thanks for any advice on this received.

Peter Reportico

Last updated

Hi there

I managed to get over my problems.

I am now able to return content back from my plugin ajax call by just echoing my html content and dying without returning back through october's ajax handling. The main thing i needed to do was to make a call to Session::save() just before my die statement to save Session parameters i was using.

My main problem for this topic post was that my session wasnt being maintained.

Peter

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.