Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

How to give correct url in ajax method.. my script working with in the project, but after deploying my web services can't reach the url.
my script like
XML
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--   <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>-->
  <!--  <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>
    <script language="javascript" type="text/javascript">
        $("#btnok").live("click", function () {
            var Title = $("#title").val();
            var Type = $("#type").val();
            var name = $("#name").val();
            var city = $("#city").val();
            var state = $("#state").val();
            var date = $("#date").val();
            var Description = $("#description").val();
            var Qualification = $("#qualification").val();
            var Compensation = "2";
            var openings = "20";
            var phone = "999999999";
            var email = "test@gmail.com";
            var zipcode = "56432";
            var job_categories = "5";
            var client_id = "1";
            var data = "{Title:" + JSON.stringify(Title) + ",Type:" + JSON.stringify(Type) + ",Description:" + JSON.stringify(Description) + ",Qualification:" + JSON.stringify(Qualification) + ",Compensation:" + JSON.stringify(Compensation) + ",openings:" + JSON.stringify(openings) + ",city:" + JSON.stringify(city) + ",state:" + JSON.stringify(state) + ",name:" + JSON.stringify(name) + ",phone:" + JSON.stringify(phone) + ",email:" + JSON.stringify(email) + ",date:" + JSON.stringify(date) + ",zipcode:" + JSON.stringify(zipcode) + ",job_categories:" + JSON.stringify(job_categories) + ",client_id:" + JSON.stringify(client_id) + "}";
          //  alert(data);
            $.ajax({
                type: "POST",
                url: "http://192.168.1.100:85/HostingService.asmx?op=SETPostJobDetails",
                data: "{Title:" + JSON.stringify(Title) + ",Type:" + JSON.stringify(Type) + ",Description:" + JSON.stringify(Description) + ",Qualification:" + JSON.stringify(Qualification) + ",Compensation:" + JSON.stringify(Compensation) + ",openings:" + JSON.stringify(openings) + ",city:" + JSON.stringify(city) + ",state:" + JSON.stringify(state) + ",name:" + JSON.stringify(name) + ",phone:" + JSON.stringify(phone) + ",email:" + JSON.stringify(email) + ",date:" + JSON.stringify(date) + ",zipcode:" + JSON.stringify(zipcode) + ",job_categories:" + JSON.stringify(job_categories) + ",client_id:" + JSON.stringify(client_id) + "}",
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (data, status) {
                    alert(data.d);
                },
                error: function (data, status, error) {
                    alert(error);
                }
//                  error: function(xhr, ajaxOptions, thrownError){
//            alert(thrownError);
//      }
            });
        });

    </script>


how to given url line.. please help me
Posted
Comments
Sandeep Mewara 7-Jan-13 9:57am    
Whats the issue with URL? Is that not working and up? If not, find the correct hosted URL and use it.
ZurdoDev 7-Jan-13 10:01am    
Is there an error? I know IE has a setting to disable cross domain script requests.
Santhosh23 7-Jan-13 10:16am    
hi,
jquery was not called. and it's show the empty alert box.

please help me
Member 9581488 7-Jan-13 10:39am    
just an idea:
url: "http://192.168.1.100:85/HostingService.asmx?op=SETPostJobDetails"
try using
url: "http://192.168.1.100:85/HostingService.asmx/SETPostJobDetails"
Santhosh23 7-Jan-13 10:58am    
thanq for replay,
but cant work am tried

1 solution

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