Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: jQuery JSONP WebService
Here is My code ..could anyone please solve this problem..I was struggling from morning..below code is not working.Actually i should get the data when we send jasondata as input..but i am getting error.its a public web-service site.
 
<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 = "{" + 'CountryName:' + searchText + "}";
        $.ajax({
            url: "http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?callback=?",
            dataType: "jsonp",
            crossDomain: true,
            jsonpCallback: 'blah',
            data:jasonData,
            contentType: "application/json; charset=utf-8",
            success: function (data, status) {
                alert(status+" status");
            },
            error: function () { alert("error"); }
        });
 
    }
    function blah(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>
Posted 7-Jan-13 21:21pm
Edited 8-Jan-13 19:09pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Following should help:
Refer: JSON and JSONP[^]
Example implementation: Cross-domain JSONP with jQuery call step-by-step guide [^]
  Permalink  
Comments
Marcus Kramer at 8-Jan-13 11:14am
   
+5. Looks like a good solution.
Sandeep Mewara at 8-Jan-13 11:18am
   
Yep. I too think so. :)
revanthkumar.ch at 9-Jan-13 0:37am
   
how can i do it client side..without server side coding..i mean i just need to pass the remote web service URL by passing json data as i/p and get the o/p.i tried all the possible ways but couldn't get result. i tried with this webservice
Clich here to see the webservice url by passing input in json format. but i am not getting output.
revanthkumar.ch at 9-Jan-13 0:39am
   
how can i do it client side..without server side coding..i mean i just need to pass the remote web service URL by passing json data as i/p and get the o/p.i tried all the possible ways but couldn't get result. i tried with this webservice
Clich here to see the webservice url by passing input in json format. but i am not getting output.

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



Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 9 Jan 2013
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