[xwiki-users] Stéphane LASSIRE est en congés.

2015-02-21 Thread Stéphane LASSIRE

Je serai absent(e) à partir du  21/02/2015 de retour le 25/02/2015.

je suis en congés.
Je répondrai à vos messages dès mon retour.
En cas de problème technique, veuillez contacter SYNOX au 05 67 34 66 56.
Merci

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Javascript RESTful

2015-02-21 Thread Matthias Wegner
Hello,

i like the REST-API and have a library in Java which works perfect. Now i
want to use the RESTful API in Javascript. But i am new to javascript and
tried a lot, but nothing seems to work. Is there a simple example in
javascript with the rest-api?

I don't get what i am doing wrong, because i am not good in javascript.

I tried

require(['jquery'], function ($) {
  $.ajax({
 accepts: {xml: 'text/xml', text: 'text/plain'},
 url: 'http://HOST/xwiki/rest',
type: 'GET',
 dataType: 'xml',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
 converters: {'text xml': jQuery.parseXML},
 crossDomain: true,
 async: true,
 username: 'username',
 password: 'apassword',
 success: function(data){
alert(Success: +JSON.stringify(data));
 },
error: function(data){
alert(Error: + JSON.stringify(data));
 }
  });
});

Also i tried

var httpRequest = new XMLHttpRequest();
httpRequest.open('PUT', 'http://HOST/xwiki/rest');
httpRequest.setRequestHeader('Accept', 'application/xml'); 
httpRequest.send( null );
alert( JSON.stringify(httpRequest.responseText) );
httpRequest.onreadystatechange = function(){
  if(this.readyState == 4){
   if(this.status == 200){
 alert(this.responseText);
   }
   else{
 alert(this.statusText);
   }
  }
}

I recognized a difference in ajax when i switched to jsonp because i tried
on localhost. But anyway my example work when i use my server outside.

Can you help me?

Regards,
Matthias



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Javascript-RESTful-tp7594084.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users