How to use JSON correctly in an HTML email - html

I have an HTML-Email, that looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
</head>
<body>
<p>Do not change next section</p>
<pre>
{
"from": "..",
"to": "..",
"statistic": {..},
"creationDate": ".."
}
</pre>
</body>
</html>
Sending this Email content with Outlook-Exchange it encodes the JSON inside the HTML to:
{
"from": "...",
..
}
Sending it with Mailcatcher it works ("from": "2019-08-01",..).
I use javamail for sending and receiving emails.

Related

Taking the input field from a JSON

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test AJAX</title>
</head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
function send()
{
var index = $('#index').val();
$(document).ready(function() {
$("#submit").click(function(event){
$.getJSON('bursa.json', function(jd) {
$('#Reserved').html('<p>' + jd.response[0].index + '</p>');
});
});
});
}
</script>
<body>
<form method="get">
Select <input type="text" id="index"><br>
<input type="button" id="submit" onclick="send()" value="Submit">
</form>
<div id="Reserved" style="border:1px solid red; height: 300px; width:400px"></div>
</body>
</html>
I'm a beginner with Jquery and I've been trying to get some data from some JSON file I created for a test. Basically what I want is to be able to allow the user to select the field he wants from the json document. My json file looks like this
"response": [
{
"c": "205.84",
"h": "206.70",
"l": "204.27",
"ch": "-1.57",
"cp": "-0.76%",
"t": "1611349199",
"s": "BA",
"cty": "united-states",
"ccy": "USD",
"exch": "NYSE",
"id": "1",
"tm": "2021-01-22 20:59:59"
},
If I try to print jd.response[0].cty for example it correctly shows "united-states", but what I want as I said is to allow the user to select his own field.. With what I've done so far it only shows "undefined". Thanks in advance for the help.
Instead of using .index, use [index]:
$('#Reserved').html('<p>' + jd.response[0][index] + '</p>');
Also called bracket notation

I would like to modify the output of Webgl Platform Building with Unity3D

Building with WebGL creates one HTML file and one Build folder.
Remove the Build/Aa.json file from here orIt should be modified to js.
Now I'm trying to put json's content in HTML but it doesn't work.
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | TyphoonFloodRiskAssessment</title>
<script src="Build/UnityLoader.js"></script>
<script>
var json = {
"companyName": "aaaaa",
"productName": "aa",
"dataUrl": "aa_Build.data.unityweb",
"wasmCodeUrl": "aa_Build.wasm.code.unityweb",
"wasmFrameworkUrl": "aa_Build.wasm.framework.unityweb",
"TOTAL_MEMORY": 268435456,
"graphicsAPI": ["WebGL 2.0", "WebGL 1.0"],
"webglContextAttributes": {"preserveDrawingBuffer": false},
"splashScreenStyle": "Dark",
"backgroundColor": "#231F20"
};
var data = JSON.parse(json);
var gameInstance = UnityLoader.instantiate("gameContainer",
data
);
</script>
</head>
<body>
<div id="gameContainer" style="width: 1012px; height: 650px; margin: auto"></div>
</body>
</html>
The content of "var = json" is the content of aa.json.
How can you solve it?

Weebly Uncaught SyntaxError: Unexpected token < in JSON at position 0

I am trying to implement my unity app for my Weebly site. I followed this tutorial: https://www.youtube.com/watch?v=mf-yNlMLcqA
I have these two codes:
1.
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | LearningEffective</title>
<script
src="https://pamaentertainment.weebly.com/files/theme/Build/UnityLoader.js">
</script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer",
"https://pamaentertainment.weebly.com/files/theme/Build/Learning Effective
online.json");
</script>
</head>
<body>
<div id="gameContainer" style="width: 720px; height: 1280px; margin: auto">
</div>
</body>
</html>
2.
{
"companyName": "pama",
"productName": "LearningEffective",
"dataUrl": "https://pamaentertainment.weebly.com/files/theme/Build/LearningEffectiveonline.data.unityweb",
"asmCodeUrl": "https://pamaentertainment.weebly.com/files/theme/Build/LearningEffectiveonline.asm.code.unityweb",
"asmMemoryUrl": "https://pamaentertainment.weebly.com/files/theme/Build/LearningEffectiveonline.asm.memory.unityweb",
"asmFrameworkUrl": "https://pamaentertainment.weebly.com/files/theme/Build/LearningEffectiveonline.asm.framework.unityweb",
"TOTAL_MEMORY": 268435456,
"graphicsAPI": ["WebGL 2.0", "WebGL 1.0"],
"webglContextAttributes": {"preserveDrawingBuffer": false},
"backgroundUrl": "https://pamaentertainment.weebly.com/files/theme/Build/LearningEffectiveonline.jpg",
"splashScreenStyle": "Dark",
"backgroundColor": "#FFFFFF"
}
When I try to load the page where Weebly's embed code is, Chrome pops up a window with this: Uncaught SyntaxError: Unexpected token < in JSON at position 0.
How can I fix this?
The URL you are using has a space. The correct URL doesn't have one.
Change this:
var gameInstance = UnityLoader.instantiate("gameContainer",
"https://pamaentertainment.weebly.com/files/theme/Build/Learning Effectiveonline.json");
To this:
var gameInstance = UnityLoader.instantiate("gameContainer",
"https://pamaentertainment.weebly.com/files/theme/Build/LearningEffectiveonline.json");
You need to set up a web server.
IIS - in file web.config:
<mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
<mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />
Apache - in file .htaccess:
AddType application/octet-stream unityweb
AddType application/json json
https://forum.unity.com/threads/webgl-uncaught-syntaxerror-unexpected-token-in-json-at-position-0.466784/
https://answers.unity.com/questions/1397472/webgl-build-when-uploaded-gives-me-this-error-unca.html

ASP Classic XMLHTTP GET JSON

I am trying to retrieve the output from the a URL using XMLHTTP GET:
The output in the browser when I hit the url directly is the following:
{
"Titles": {
"resultCount": 37680,
"moreResources": true
}
}
The ASP code on test.asp I am using is:
<%#language=JScript%>
<%
var objSrvHTTP;
objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.6.0");
objSrvHTTP.open ("GET","http://someipaddress:8080/Publisher/Titles/Paging/0,0,tc?output=json", false);
objSrvHTTP.send ();
Response.ContentType = "application/json";
Response.Write (objSrvHTTP.responseText);
%>
The results displayed in browser from hitting test.asp is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>something</title>
</head>
<body>
{
"Titles": {
"resultCount": 37698,
"moreResources": true
}
}
</body>
</html>
I am looking to have just the data between the body tags returned, or even better just the value for "resultCount". Any help would be much appreciated.
You need to remove the HTML markup, when reading JSON data it should be nothing but valid JSON in the request response.

How to do html redirect in JSP?

I have the following JSP :
<%
String Target_Url=request.getSession().getAttribute("Target_Url").toString();
Target_Url="http://www.yahoo.com";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
if (window.top.location != window.location)
{
window.top.location.href=window.location.href;
}
</script>
<META http-equiv="refresh" content="0;URL=${Target_Url}">
</head>
...
</html>
It's inside a frame, and should redirect to the top level location, but it's not doing that, it keeps redirect to it self, but if I hard code it like the following, it works :
<META http-equiv="refresh" content="0;URL=http://www.yahoo.com">
I guess : content="0;URL=${Target_Url}" is incorrect, what's the correct format ?
Correct format:
<META http-equiv="refresh" content="0;URL=<%=Target_Url%>">