Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
I am created one web services my web services name "HostingService.asmx". in my web services having no of methods. am added one html page in same project, now am calling json web services using ajax,jquery. its working fine. my script code is
HTML
  <script language="javascript" type="text/javascript">
$("#btnok").live("click", function () {
            var username = $("#name").val();
            var password = $("#password").val();
            var clientid = $("#clientid").val();
            $.ajax({
                type: 'POST',
                url: 'HostingService.asmx/SETusers',
                data: "{username:" + JSON.stringify(username) + ",password:" + JSON.stringify(password) + ",clientid:" + JSON.stringify(clientid) + "}",
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (data, status) {
                    alert(data.d);
                }
            });
        });

      </script>

this script code working fine. after deploying my web services and assign to one port/IP address in server. like "http://192.168.1.100:85/HostingService.asmx?op=SETusers". this is my web services url. now am creating one html page with out project using notepad. and adding the same code just modified the url in ajax method. my url like
url: "http://192.168.1.100:85/HostingService.asmx/SETusers" and
"http://192.168.1.100:85/HostingService.asmx?op=SETusers" am tried in different ways. but my code is not working in html page. my alert box shows the empty message.
using scripts are
XML
<script src="Scripts/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script>

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  <script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>

please tel me, how to find the error, how to solve my problem.

thanking you.
Posted
Updated 8-Jan-13 4:26am
v3

1 solution

This is probably the Cross domain issue. for the cross domain you have to use the JSONP instead of JSON. Please see below for more details.

http://forums.asp.net/t/1711966.aspx/1[^]

Here is the nice article for your reference
http://bloggingabout.net/blogs/adelkhalil/archive/2009/08/14/cross-domain-jsonp-with-jquery-call-step-by-step-guide.aspx[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900