We help IT Professionals succeed at work.
Get Started

wcf, asp.net, jquery /ajax restful

ITsolutionWizard
on
423 Views
Last Modified: 2015-04-13
Below code working in IE but not Chrome.  And I verified the service actually went thought to the browser.
I believe something wrong when it is passing the parameters like below

url: GetSaleTax + encodeURIComponent("(066,''," + city + "," + state + "," + zip + ",USA)"),

But I do not know how to fix it. I also have another service call and it is working but that one does not need to pass parameters.

Second Question is: I want pass SalesTaxRate to input text box "taxRate". Please help.

return error:
XMLHttpRequest cannot load http://clientaccesstest.abc.com/wcf/orders/RestService/ProQuoteServiceJVC/GetSaleTax(066%2C''%2CCOLUMBUS%2CIN%2C47201%2CUSA)?_=1428433379116. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:62937' is therefore not allowed access.

export result after service is called:

<Status>Completed</Status><CustomerNumber></CustomerNumber><ShipToCity>COLUMBUS</ShipToCity><ShipToState>IN</ShipToState><ShipToZip>47201</ShipToZip><ShipToCountry>USA</ShipToCountry><SalesTaxRate>7.000</SalesTaxRate>

Script:

<script type="text/javascript">
    function GetSaleTaxList(city, state, zip) {

        city = "COLUMBUS";
        state = "IN";
        zip = "47201";

        var GetSaleTax = "http://clientaccesstest.abc.com/wcf/orders/RestService/ProQuoteServiceJVC/GetSaleTax";            
            if (city == '' || state == '' || zip == '' ) {
                  //setSaleTaxInfo("NO RATE");
            }else if (state == 'XX') {
                  //setSaleTaxInfo("NO RATE");
            }else{
                  $(document).ready(function () {
                              
                        //alert(GetSaleTax);
                        $.ajax({
                              cache: false,
                              type: "GET",
                              async: false,
                              dataType: "json",
                              contentType: 'text/plain',
                              url: GetSaleTax + encodeURIComponent("(066,''," + city + "," + state + "," + zip + ",USA)"),
                              success: function (data) {
                                    $('#data').html(data);
                                    alert(data + " : data");
                                    if (data == null)
                                          return;
                                    //setSaleTaxInfo(data);
                                    //resultObj = jQuery.parseJSON(data);
                                    //if (resultObj.Status != 'Failed') {
                                    //    $('#json').html(setSaleTaxInfo(resultObj.Data));
                                    //}
                              },
                              error: function (xhr) {
                                    //$('#data').html(xhr.responseText);
                                    alert(xhr.responseText + " : error GetSaleTax");

                              }
                        });
                  });
            }
}
</script>

<input type="text" name="taxRate" id="taxRate">
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 21 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE