Showing posts with label Webservice. Show all posts
Showing posts with label Webservice. Show all posts

Tuesday, 16 April 2013

Ajax request to cross domain web service

Here http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=wbp-3BJWsU8&format=json is an example URL

$.ajax({
            url: 'http://query.yahooapis.com/v1/public/yql',
                data: {
                    q: "select * from json where url ='http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=wbp-3BJWsU8&format=json'",
                    format: "json"
                },
                dataType: "jsonp",
            success: function (data) {

                alert(JSON.stringify(data));


            },
            error: function (result) {
                alert("Sorry no data found.");
            }
        });

Friday, 12 April 2013

jquery ajax call to asmx webservice in asp.net

jQuery script



$.ajax({
    type: "POST",
    url: "/WebServices/UserInfo.asmx/CheckAvailability",
    data: "{ 'Title': '" + TitleName + "' }",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (response) {
        alert(response);
    },
    error: function (data) {
        alert(data);
    }
}); 

Also made change in web config


<webservices>
      <protocols>
        <add name="HttpGet">
        <add name="HttpPost">
     </protocols>
</webservices>