here i am giving input in json format.but i am not getting the output.could any one please solve this problem.
i have some queries regarding jsonp :
1)I have a doubt inorder to call remote web services using jsonp,should we have to send data in json format or querystring format.
2)Here if we access the url and give input then we will get o/p in xml format. so i just want to know whether jsonp wont work for webservices which gives xml as output.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script>
<script type="text/javascript">
function myQuerySuggestions() {
var searchText = document.getElementById('txtsearch').value;
searchText = "'" + searchText + "'";
var jasonData = "{" + 'Celsius:' + searchText + "}";
$.ajax({
url: "http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit",
dataType: "jsonp",
crossDomain: true,
data:jasonData,
jsonpCallback: blah,
contentType: "application/json; charset=utf-8",
success: function (data, status) {
alert(status+" status");
},
error: function () { alert("error"); }
});
}
function blah(data) {
alert("called");
alert(data);
// var result = (typeof data.d) == 'string' ? eval('(' + data.d + ')') : data.d;
// $('#summary').html('<p>All new content. <em>You bet!</em></p>');
// $('#summary').html(result);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<label for="txtsearch">
Enter country:
</label>
<input type="text" id="txtsearch" size="43" style="font-size: 12px; font-weight: bold;" />
<br />
<asp:Button ID="btn" runat="server" Text="Submit" OnClientClick="myQuerySuggestions();return false;" />
<div id="summary" runat="server"></div>
</div>
</form>
</body>
</html>
Whatever service you are calling should return JSONP for Ajax call with
dataType: "jsonp"to work.XML response is not JSONP response – there is no magic conversion from one to another.