Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How to send Object as parameter to post request call

$
0
0

how to send objects has parameter to url in post request service call. LoginWindow.js

if (validateLogin()){ var httpRequest = require('HttpRequests'); httpRequest.authenicateUser(username,password); }

HttpRequests.js

httpRequests.authenicateUser = function(username,password){ var xhrLogin =Titanium.Network.createHTTPClient(); xhrLogin.onerror = function(e){ Ti.API.error('Bad Server =>'+e.error); }; var device = "abcd"; var type = "IOS"; var Channel = "Channel"; var deviceObj = {device: device,type:type, Channel: Channel}; var userObj = {username:username,password:password}; xhrLogin.open("POST","http://192.123.123.12/authentication.json"); xhrLogin.setRequestHeader("content-type", "application/json"); var param={ userObj:userObj,deviceObj:deviceObj}; xhrLogin.send(JSON.stringify(param).toString); xhrLogin.onload = function(){ Ti.API.info('Response ::'+this.responseText); } };


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>