Reputation: 31
Hi Guys I hope you can help as this is driving me up the wall !!
I am running local Vb.net web site and calling a javascript function to try to post JSON data to a php website on a web based server. My browser is IE9 and im using visual studio 2010
I started off trying to call JSON.stringify or JSON.parse and neither would work.
I added into my .aspx page the line <script type="text/javascript" src="http://www.json.org/json2.js"></script>
and it still didnt work
I downloaded a json file and referenced it locally from JSON.ORG and it still doesnt work.
When it gets to the line JSON.stringify - it returns a microsoft javascript error that JSON is not defined
I have spent two days trying to get this to run and could do with your help. Any thoughts ??
function jsonSend() {
var JSONJSON = {};
var json = document.getElementById("ctl00_ContentPlaceHolder1_JsonTfr").value;
JSONJSON['insc_users'] = json;
var jsonStr = JSON.stringify(JSONJSON); //**this is where it fails**
$.ajax({
type: 'POST',
url: 'http://www.thiswebsite.co.uk/receive.php',
dataType: 'json',
data: jsonStr,
success: function (data) {
// handleLoginLocally(u, p);
console.log('LOG.LOGIN: trying login using local storage');
},
error: function () {
console.log('LOG.LOGIN: login remote server failed');
// handleLoginLocally(u, p);
console.log('LOG.LOGIN: trying login using local storage');
}
});
Upvotes: 1
Views: 2843
Reputation: 172428
You can try adding <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.01 Transitional//EN">
or <!DOCTYPE html>
Also check this.
Upvotes: 2