Click here to Skip to main content
12,353,329 members (69,364 online)
Rate this:
 
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 17: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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2016
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