Hi guys i was wondering if sort of MODx API for Ajax snippets exists... i’m really interested in found some way to use modx dbAPI in my php code to make ajax snippets
i have been looking in the ajaxsearch code but it doesn’t use the dbapi, just plain mysql queries for ajax calls why is that?
example
if($ajaxSearch){
common sql} else{
dbapi access}
i want to use api functions like makeArray or getChunk... but i cant (what i’m doing wrong??)
thanks guys!
visit us at www.dospuntocero.cl
-
MODX Staff
- 10,725 Posts
Why not write snippets for your Ajax requests and execute them as documents in your site? This is how I use Ajax with MODx when I want to have access to the MODx API. Just have it return the JSON or HTML (or whatever form of) response.
I also have had success with what OpenGeek recommends.
I create a snippet to process the ajax request(s) then create a new document with a blank template (so no other output is generated) and place only my AJAX snippet call on that page.
Then in my site where I want to use POST or GET to send an AJAX message and get a response I post my calls to that document using Hijax.
Let’s say this blank page with the AJAX snippet call on it has a document ID of 55.
In my page where I have a form for sending asynchronous messages, I use javascript (I prefer jQuery) to hijack the form and instead of posting it normally, post it to "index.php?id=55".
Please feel free to ask for more details if you would like them.
-sD-
Dr. Scotty Delicious, Scientist DFPA.
Quote from: dev_cw at Sep 14, 2007, 09:00 AM
Quote from: MotSmart at Sep 14, 2007, 04:52 AM
Wiki worthy topic if there is not yet and someone have time to do, perhaps some tutorial would address new commers to Ajax and MODx 
Yes, this would be a nice wiki topic 
thanks guys, i’ll start the tests right now, if i have some doubts, i’ll ask again, when i finished i’ll post it in the wiki both spanish and english (for that reason my english sucks sometimes...)
right now i have some working stuff, using index-ajax.php, but my main problem is i cant do modx logic (DBAPI access or $modx-> stuff) in an external php file, hope this could be resolved with your idea of blank file with snippet (i’m not a seasoned php developer, just a noob good only with actionscript)
thanks pals
visit us at www.dospuntocero.cl
well guys as i promised, i have posted in the wiki my "framework" to do ajax stuff in MODx

thanks for your guidance, i’m really happy to see lots of heavyweights in answering my question, so in retribution I contribute to the comunity with my new know how
http://wiki.modxcms.com/index.php/Use_AJAX_with_modxAPI
visit us at www.dospuntocero.cl