Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
in Q2A Core by
I'm working on a plugin without a page, but I would like to know how I can get it to receive Ajax calls and respond. Is this do-able?


I tried making a process module, but it won't work.
Q2A version: 1.6.1

2 Answers

+1 vote

Did you try ajax method of jQuery? -> http://api.jquery.com/jQuery.ajax/

The method that I use well is below.

  • Request data: $_POST / $_GET
  • Response data: JSON (json_encode()).

My some plugin("Notification Pro", "Mass Mailing Pro", etc) uses this simple interface. Because coding method of Javascript and PHP has nothing to do with Q2A, you can study on internet.

I have to upload a file, so I'm using the jQuery Form Plugin. But when I call ajaxSubmit it doesn't seem to call the file properly.

I wrote a JS file and put it under homepage.
I also has a widget on homepage to display some additional button.
Then I bind the click event to my JS such that it will send AJAX request to the back-end PHP page under 'qa-plugin/myplugin/' folder. The PHP page will echo result as JSON so we should catch it in JS file.
The problem is the page was redirected to the index page of qa-plugin folder and I cannot open my PHP file to see the result of ECHO.
Do you have any idea how I can successfully get the AJAX result data?
+1 vote
Check my star rating plugins.. Its free so download the plugin and look in to files. You will get exact idea. Get from here http://store.q2amarket.com/store/products/q2am-star-ratings/
Hm I'll look into it but I'm trying to upload a file. Thanks already!