I have tried sending this string from my asp page.

https://api.qualifiedaddress.com/street-address/?street=3634+Banksstreet=3634+Banks&city=Butte&state=MT&state=MT&zipcode=59701&candidates=1&auth-token=[removed]

I get no return and the number of requests does not increment. I have an onblur for the zipcode field that calls a function amidone in the function I call:

var amidone = function() {
            var url = addressString;
            $("#AddressReturn").html(addressString); // display the url value on the page
            $.getJSON(url, function(data) {
                $("#AddressReturn").html(data.length);
              if (data.length == 0){
                $('#Address1').val(data[0].delivery_line1);
                $('#Address2').val(data[0].delivery_line2);
                $('#city').val(data[0].city_name);
                $('#state').val(data[0].state_abbreviation);
                $('#zipcode').val(data[0].zipcode + "-" + data[0].plus4_code);
                $('#AddressElements :input').attr('disabled', true);
                $("#AddressReturn").html("Valid Address");
            } else {               
                $("#AddressReturn").html("Invalid Address");
           }// End of data.lengh check
            }); // End $.getJSON
        } //  end amidoneThis getJSON routine

I am a fair ASP programmer, this jquery/JSON stuff is very new to me. Can you tell what I have done wrong? Or where do I go for help?

asked 13 Feb, 17:16

Questions's gravatar image

Questions ♦♦
40182318
accept rate: 15%

edited 13 Feb, 17:19

This almost looks like an invalid cross domain request. The get Json call needs datatype jsonp or the browser will block it.

OK, I used Chrome and opened the console and got this after a request.

XMLHttpRequest cannot load https://api.qualifiedaddress.com/street-address/?street=Here+At+Home&street2=&city=Whatsit&state=ID&zipcode=98554&candidates=1&auth-token=[removed].

Origin http://[removed] is not allowed by Access-Control-Allow-Origin.

Does this make sense? I added the www.nwcctan.com on the Authorized Domains under the Verification API page.

(13 Feb, 17:19) Questions ♦♦

Try this example out:

https://github.com/smartystreets/LiveAddressSamples/blob/master/jQuery/street-address.html

It uses jQuery.axax and explicitly sets the dataType to "JSONP".

Also, because you are using the REST api you don't need to authorize a domain on the management console. Just make sure you're using an active Authentication Token in the query parameter data.

link

answered 13 Feb, 17:20

Jeffrey%20-%20SmartyStreets's gravatar image

Jeffrey - SmartyStreets ♦♦
2.2k14
accept rate: 50%

Thank you, I was able to get a result set. I have spent a bit of time trying to figure out how to reference the elements of the data return. I have tried serializeArry .data() and many other options as well as data[0].delivery_line1… I really appreciate your assistance and I am sure it is simple.

(13 Feb, 17:20) Questions ♦♦

Not a problem. The data that comes back is a JSON so it's actually just like a javascript array that consists of zero or more javascript objects. Supposing there's one valid address suggestion you would access the dpv_match_code field like this:

data[0].analysis.dpv_match_code

I recommend setting a javascript breakpoint using your browser's developer tools. Set the breakpoint right after the response comes back (like on line 24 of the Github example in the last message). Once you are stopped on that breakpoint you can play around with the 'data' variable in the console window or in the 'locals' section of the scripts window. I've attached a few screenshots of my debug session that hopefully clear up this explanation.

Hope that helps...

I meant to get back to you. I did figure it out. my main problem was I did not use the proper variable name! Thank you very much for your time.

(13 Feb, 17:22) Questions ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×47
×23
×2
×2

Asked: 13 Feb, 17:16

Seen: 241 times

Last updated: 13 Feb, 17:22