Calling API with jQuery/Javascript Version 2.0

4 years 1 week ago #93984 by FrAgFo0d
Has anyone here have any knowledge about using jQuery to connect to the API?
I am using Limesurvey version 2.00 and setup the JSON-RPC.

I did a test on the API with
The response I get is: "Invalid user name or password"

That seems O.K. to me.

But I tried several things with jQuery using $.ajax() and $.post()
trying to use: get_session_key however the API is non responsive.

So can anyone help me on the way with a small example of how this should work?

Please Log in to join the conversation.

4 years 1 week ago #94002 by FrAgFo0d
So here is some more info.
This doesn't work (yet).

I do get a success from jQuery, however there is no response what so ever from the API (in Firebug).
Which basically means that jQuery did load the page, but the page was blank.
var params = {
    "method": "get_session_key",
    "params": {
        "username" : "admin",
        "password" : "test"
    id: 1,
    jsonrpc: "2.0"
    url: "http://LimeSurvey/index.php/admin/remotecontrol",
    type: "POST",
    contentType: "application/json",
    data: JSON.stringify(params),
    error: function(data) {
    success: function(data) {

Please Log in to join the conversation.

4 years 1 week ago #94018 by FrAgFo0d
OK So I am also checking it out in the Dutch forum.

Somehow I can send the data to the API, but there is just no response from the API.
I checked my HTML Request headers and my POST body in Firebug and get this:
Accept	*/*
Accept-Encoding	gzip, deflate
Accept-Language	en-US,en;q=0.5
Content-Length	83
Content-Type	application/json; charset=UTF-8
User-Agent	Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/20100101 Firefox/19.0
X-Requested-With	XMLHttpRequest
POST body:

This is my Response Header:
Cache-Control	no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection	Keep-Alive
Content-Encoding	gzip
Content-Length	20
Content-Type	text/html
Date	Tue, 19 Mar 2013 15:23:41 GMT
Expires	Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive	timeout=15, max=99
Pragma	no-cache
Server	Apache/2.2.16 (Debian)
Vary	Accept-Encoding
X-Powered-By	PHP/5.3.3-7+squeeze15

I do not get any response body.
Could anybody help me out with this?

Please Log in to join the conversation.