I know this is possible in Java with Javascript handler :
graphView.addJavascriptInterface(handler, "javahandler");
graphView.loadUrl("file:///android_asset/html/show_data_from_file.html");
JSONObject json = new JSONObject();
json.put("data", jsonArray);
json.put("label","labelString");
handler.json = json;
Within the javascript page, the "javahandler" would have "json" object, which I can get the data array and the label to display on the page.
Is there something similar for iOS? I'm very new to web programming with iOs, and would appreciate your help!
You can use stringByEvaluatingJavascriptFromString to call a javascript method and pass your JSON string through that method,
[yourWebViewInstance stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:#"useThisJSONString(%#)", JSONString]];
Related
How to use this <Label>k__BackingField: "Aachi" type of data value in ionic?
enter image description here
I am getting this response in the ionic rest API response. API made in ASP .net.
Here is a working example.
export interface YourInterface {
"<Label>k__BackingField": string;
}
let value: YourInterface = { '<Label>k__BackingField': 'Aachi' };
console.log(value['<Label>k__BackingField']); // Outputs 'Aachi'
However, I would recommand renaming/mapping the properties so you can access them with . instead of []. For example, you can have an interface for your raw API response, another interface with 'valid' property names, and a function that converts one to the other, and/or vice versa if needed.
So basically I have a QR code generator in the app, I already implemented a feature generating it with url, such as domain.com/userid?=111.
So, now I want QR code scanner to scan it and get only the id part of the user out of it, like it scanned the url example provided above, and then I just want to get '111' part to process.
How can I implement it?
Use Uri queryParametersAll:
Uri url = Uri.parse('https://www.example.com/?userid=111');
print(url.queryParametersAll['userid'][0]);
You can use substring method to get the part of it.
// Dart 2.6.1
main() {
String str = "domain.com/userid?=111";
print(str.substring(str.indexOf("=")+1));
}
I can set a GET method in Slim to get data from my database but my problem is the POST method, i don't know how to use it correctly. I do some code like:
$app->post('/login',function() use ($app){
$inputs = json_decode($app->request()->getBody());
$result = json_encode($inputs);
return $result;
});
I wanna make a login function by POST method but this is just an example I want to show the data that have been sent in the body by json. I used Advanced Rest Client to test but the result is always "null".
I'm new to Rest and Slim Framework too. Thanks for any helpful idea !
using return doesn't do anything in terms of viewing the output within that route callback function. use print, print_r, echo, $app->response->setBody('Foo'), or $app->response->write('Foo')
in terms of the post, did you try using $data = $app->request()->post() to get your data?
I am new in extjs. I need to know how to make ajax call in extjs and display the json values in inside div. I don't need to use grid..
In ExtJS, you will have to use the Ext.Ajax class to make ajax calls to a remote server. Following is a typical code showing how to do it:
Ext.Ajax.request({
url: 'ajax_demo/sample.json',
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
console.dir(obj);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});
In case of HTTP success (200 OK), the control will go inside the success callback and the first things that we have to do is decode the response.responseText which will give you the JSON response coming from the back-end data source.
Once you have code the JSON, you are free to format it and add it to any element (say to a div in your case). In case you want to format the JSON data nicely before adding, you may do that using Template/XTemplate.
I have used something like this.
$.getJSON('somepathtoserver/somefile.php?callback?', variable,function(res){
});
In the somefile.php, I have a callback function that processes and return the value to the js function.
like this:
{
echo $_GET['callback']. '(' . "{'someValue' : $calculatedVariable}" . ')';
}
This is tricky, but very useful when trying to ajax from one server to a different server, which is the reason I would use JSON here and not just a straight AJAX request.
I'm using XhmHttp request object to send SOAP request to web services from classic asp page. The web service is returning xml string as result how can I read the xml string result from the SOAP response. Is there any property or method in the XmlHttp object supports that?
vb example:
Dim xmlhttp As New Msxml2.XMLHTTP30
xmlhttp.open "GET", "http://localhost/books.xml", False
xmlhttp.send
MsgBox xmlhttp.responseXML.xml
have a look at the description
responseXML Property
You should be able to use the regular XMLDOM object to do the whole thing. You just 'load' the document right from the URL of the web service you're talking to.
set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async=false
xmlDoc.load("http://server.domain.com/yourservice.asp?arg1=a")
Then you just continue parsing the document as if you had loaded it up from a local file.