View Full Version : Call USPS API

25 Jan 2013, 8:37 AM
I want to call a USPS API behind the scenes when a user enters a zip code and exits the field. Showing what I've tried will only make it confusing, but I don't want to just ask for help without showing I've made an attempt!

My Store Code ... but with this MVC fogging my head I don't even know how to load my store outside of making it autoLoad : true .... which defeats the purpose!

When I did have autoLoad : true I could see the url request in Firefox, but there was no response. The url went over with an OPTIONS tag instead of GET or POST. Odd!

Ext.define('AC37.store.USPS', {
extend : 'Ext.data.Store',
fields : [{
name : 'city'
}, {
name : 'state'
proxy : {
type : 'ajax',
url : 'http://production.shippingapis.com/ShippingAPI.dll',
reader : {
type : 'xml',
root : 'ZipCode',
record : 'record'
actionMethods : {
read : 'POST'
extraParams : {
API : 'CityStateLookup',
XML : '<CityStateLookupRequest USERID="xxxxx"><ZipCode ID="0"><Zip5>19056</Zip5></ZipCode></CityStateLookupRequest>'
autoLoad : false

25 Jan 2013, 8:54 AM
The OPTIONS requests is a result of attempting to access a different domain. It's part of cross-origin resource sharing (CORS).


For alternatives to autoLoad, see the introduction at the top of the docs for store:


Methods such as load and loadPage in particular are worth understanding.

Don't even think about the MVC until you have a firm grasp of core concepts like components and stores.

25 Jan 2013, 8:59 AM
Thanks. I'll check the links out. Thought I had a grasp on things with 3.4 ... actually have some complex apps going ... although everything is in one huge mess of a 2000 line .js file!