Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax jQuery JSON
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
   <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
<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 8-Jan-13 2:13am
Edited 8-Jan-13 5:26am
v3

1 solution

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

Solution 1

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[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 8 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