Question

I would like to use the Limesurvey API with jquery. When I try to get the session-key with the following code I get the error message 631: failed to parse request, when I enable the xml rpc. And no response when json-rpc is enabled.

 $.post("url_to_survey/index.php/admin/remotecontrol",{
                username : "foo", password : "bar"
                },
                function(data) {
                   alert('sessionKey: ' + data);
                }
    );

Could anyone post an example query, please?

Was it helpful?

Solution

Try to force the dataType parameter to your request, like this :

$.post("url_to_survey/index.php/admin/remotecontrol",
  {method : 'get_session_key', username : "foo", password : "bar" },
  function(data) {
      alert('sessionKey: ' + data);
  }, 
  'json'
);

Use dataType: "json" if you enable json-rpc, etc.

Edit : just add the method name

OTHER TIPS

It works by using the mimic library with xmp-rpc enabled.

var method = "get_session_key";  
var request = new XmlRpcRequest(input, method);  
request.addParam("your_username");  
request.addParam("your_password");  
var response = request.send();  
alert(response.parseXML());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top