언어 설정

Menu
Sites
Language
XMLHttpRequest doesn't work

HI i am trying generate Zypr Token with following code...

/*******************CODE***************************/

 var xmlHttp = null;
            var theUrl = "https://pais-dev.zypr.net/api/v2/auth/login/?username=anonymous&key={2ad5196442833a888db21a2fdfd56a77}";
            localStorage.setItem('theUrl', theUrl);
             
            xmlHttp = new XMLHttpRequest();
            xmlHttp.open("GET", theUrl, false);
            console.log(xmlHttp.readyState);
            xmlHttp.send(null);
           
            var strData = JSON.parse(xmlHttp.responseText);
             console.log(xmlHttp.responseText);
            if (strData.response.information.code == 200) {
                _token = strData.response.data[0].token;
                localStorage['_zyprtoken'] = _token;

/*******************CODE***************************/

 

It is work well in web simulator ,but not tizen emulator.

i am getting xmlHttp.readyState=1 (which means connected to server)

and getting the following error

pocjs/hndapi.js (14) :ABORT_ERR: XMLHttpRequest Exception 102: The user aborted a request in synchronous requests.

it working in all browsers and tizen web simulator except EMULATOR.

Edited by: Brock Boland on 17 3월, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

3 댓글
Lakshmi Grandhi
Hi Nitish, There is sample application which uses XHR, please go through it, if you still are facing issue, let me know. https://developer.tizen.org/documentation/social-network-services-tizen
Varsamis
Hi, I'm trying to make bing-translate work on Tizen. Here's a related guide: http://blogs.msdn.com/b/translation/p/gettingstarted2.aspx I currently can't get the data from the GET request. I read the article on implementing social network services; the 2nd way (code in comments) comes from there. The first GET is a slight different version of that. output of 1st method: wgt/scripts/Translate.js (147) :TypeError: 'null' is not an object wgt/scripts/Translate.js (147) :Error: ABORT_ERR: XMLHttpRequest Exception 102 output of 2nd: wgt/scripts/Translate.js (166) :parsererror wgt/scripts/Translate.js (166) :null (btw, I tried to get the translation with curl in command line and it worked. It returns an xml file with a string tag containing the translated text) I'd appreciate any help on that. Thanks $.post("https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/", { "client_id": "whateverwhatever", "client_secret": "whateverwhatever", "scope": "http://api.microsofttranslator.com/", "grant_type": "client_credentials" }, function(data){ acc_token = "Bearer " + data.access_token; $.ajax({ type: "GET", url: "http://api.microsofttranslator.com/v2/Http.svc/Translate?text=hello&from=en&to=es", beforeSend: function(request){ request.setRequestHeader('Authorization', acc_token); }, dataType: 'xml', async: false, success:function(response){ console.log("success " + response); }, error: function (request, status, error) { line 147 -> console.log(error); } }); /* 2nd way $.ajax({ type : "GET", dataType : 'xml', url : "http://api.microsofttranslator.com/v2/Http.svc/Translate?text=hello&from=en&to=es", headers : { "Authorization" : acc_token, }, async: false, success : function(mydata) { console.log(mydata); $(mydata).find('string').text(); }, error : function(mydata, textStatus) { line 166 -> console.log(textStatus); } }); */ }, "json");
Lakshmi Grandhi
Hi, Below code is working fine theUrl = 'http://api.microsofttranslator.com/V2/Http.svc/Translate?oncomplete=mycallback&appId=8B841CA7C1A03443682C52AD07B7775A7BD5B3AA&from=en&to=fr&text="testing sample"' ; xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", theUrl, false); xmlHttp.send(null); var xmlDoc = xmlHttp.responseXML ; console.log( xmlDoc.getElementsByTagName("string")[0].childNodes[0].nodeValue); for ajax request u have to use ajax url "http://api.microsofttranslator.com/V2/Ajax.svc/Translate"