是 worklight 的新手,在我的应用程序中,我通过 work-light 适配器获取 JSON 响应。在模拟器中,只有在调用 work-light 过程后,响应才会正确显示。但是当我在真实设备中运行它时没有显示响应。任何人都可以帮助我解决这个问题。
我的适配器 XML 代码:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-G92 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="JSON"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>JSON</displayName>
<description>JSON</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>www.name.in</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getJSONs"> </procedure>
<procedure name="addJSON"> </procedure>
<procedure name="updateJSON"> </procedure>
<procedure name="deleteJSON"> </procedure>
我的适配器JS代码:
function getJSONs() {
var input = {
method : 'get',
returnedContentType : 'json',
path : 'getMerchantdetails?json=',
};
return WL.Server.invokeHttp(input);
}
我的主要 JS 代码
function wlCommonInit(){
busyIndicator = new WL.BusyIndicator("view0");
// Common initialization code goes here
$("#btn").click(function(){
getJSONs();
});
}
function getJSONs(){
//busyIndicator.show();
var invocationData =
{
adapter : "JSON",
procedure : "getJSONs",
parameters : []
};
WL.Client.invokeProcedure(invocationData,
{
onSuccess : merchantdetails,
//onFailure : mobGmapLatLngFailure,
});
function merchantdetails(result) {
var httpStatusCode = result.status;
//var div = $("#invokeResult");
if (200 == httpStatusCode) {
var invocationResult = result.invocationResult;
var isSuccessful = invocationResult.isSuccessful;
if (true == isSuccessful) {
var result = invocationResult.merchant_detail;
//alert(result[0].merchant_long_desc+" - "+result[0].merchant_contact_number);
$("#txt").html(result[0].merchant_long_desc+" - "+result[0].merchant_contact_number);
} else {
//div.append("Request Failed!");
}
} else {
//div.append("Request Failed!");
}
}
}
我的儿子回应
"merchant_detail": [
{
"merchant_code": "1",
"merchant_contact_number": "2147483647",
"merchant_logo": "",
"merchant_long_desc": "Anjappar",
"merchant_short_desc": "Anjappar",
"merchant_type_code": "1"
}
],