INDEX.XML
<Alloy>
<Window class="container">
<Label id="label">login here</Label>
<TextField id="txtUser">username</TextField>
<TextField id="pwd">password</TextField>
<Button id="btnLogin" onClick="doLogin"></Button>
</Window>
</Alloy>
index.js
function doLogin(e) {
var name = $.txtUser.value.toString();//txtUser is my textbox id
var paswd = $.pwd.value.toString(); //pwd is my textbox id
var jsonobject = {"username":'"'+name+'"',"password":'"'+ paswd+'"'};
var url="api.usergrid.com/DHEERAJ123/DEMO1/logs?";
var client = Ti.Network.createHTTPClient({
onload:{ },
onerror :{ }
});
client.setRequestHeader('content-type', 'JSON');
client.open("POST", url);
client.send(JSON.stringify(jsonobject));
}
$.index.open();
apigee baas output
{
"uuid": "6f07d50a-c48b-11e4-939c-ab932c123bc7",
"type": "logs",
"created": 1425706387024,
"modified": 1425706387024,
"metadata": {
"path": "/logs/6f07d50a-c48b-11e4-939c-ab932c123bc7"
},
"password": "\"888\"", // i had sent 888 but it come .....
"username": "\"dheeraj\""// i had sent dheeraj but it save.....
}
当我通过最终用户使用钛合金在apigee中插入数据时,apigee中的数据不能以适当的格式保存,在apigee附加\和“”即将到来...... 如何克服这个问题......
答案 0 :(得分:0)
我想这个:
var jsonobject = {"username":'"'+name+'"',"password":'"'+ paswd+'"'};
应该是:
var jsonobject = {"username":name,"password":paswd};