Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I am developing an application in that i have to get data from a web service for that i have used javascript and json the code is working in IE only and i want all browser compatibility
Posted 5-Nov-12 18:30pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

var options = {
 
type: "POST",
contentType: "application/json",
url: ImportInquiryurl,
data: JSON.parse(objinquirys),
dataType: "json",
success: function (msg) {
document.getElementById('<%= txtFirstname.ClientID %>').value = "";
document.getElementById('<%= txtLastName.ClientID %>').value = "";
document.getElementById('<%= txtCompanyName.ClientID %>').value = "";
document.getElementById('<%= txtPhoneNumber.ClientID %>').value = "";
document.getElementById('<%= txtemailaddress.ClientID %>').value = "";
document.getElementById('<%= txtTopic.ClientID %>').value = "";
document.getElementById('<%= txtNotes.ClientID %>').value = "";
document.getElementById('<%= txtZip.ClientID %>').value = "";
document.getElementById('<%= ltrMessage.ClientID %>').innerHTML = "Inquiry Created Successfully";
},
failure: function (error) {
}
};
$.ajax(options);
 

 

The code for which i want browser compatibility
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Unfortunately IE still doesn't support native JSON. There is a very good polyfill. Called JSON2. Here is the CDN;
http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js[^]
  Permalink  
Comments
Meghal Modi at 6-Nov-12 23:50pm
   
This works well with IE but doesnt work with Chrome,FF and Safari.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 244
3 BillWoodruff 210
4 Maciej Los 192
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100