views:

114

answers:

3

So I have a bit of a problem. When I ask MooTools to send a request it comes back as failed every time. I can't seem to diagnose the problem either because if I try to get the returned header info the console just gives me "Refused to get unsafe header 'Status'" Message. The only thing I can think of is that the server isn't letting me access outside resources but maybe I just coded it wrong.

Here's the request code:

var finfo = current.textFontData();

var url = 'http://antiradiant.com/clients/TMW/rbwizard/mailer.php?s='+current.size+'&b='+current.box+'&l='+current.lidWood+'&c='+current.cartID+'&f='+finfo.font+'&l1='+finfo.line1+'&l2='+finfo.line2;
console.log(url);

var req = new Request({
    url: url,
    onSuccess: function() {
        console.log('success');
        //atc2.send();
    },
    onFailure: function() {
        console.log('failure');
        console.log(this.getHeader('Status'));
        //atc2.send();
    },
    onException: function(headerName, value) {
        console.log('exception');
        console.log(headerName+': '+value);
    }
});

req.send();

This code is derived from the resource rb_wizard.js (lines 81-103) on http://tylermorriswoodworking.myshopify.com/pages/recipe-box-wizard?b=maple&l=cherry&s=3x5&c=42042892

+1  A: 

The error message "Refused to get unsafe header 'Status'" is spat out by WebKit based browsers (Safari, Chrome, etc) when you violate the cross-domain security model.

Therefore, it seems likely that the code you pasted is located on a domain other than antiradiant.com, and therefore is not allowed (by the browser) to request sites on antiradiant.com.

tomit
+2  A: 

Mootools has a class called Request.JSONP that will help with your cross domain problem. Its sub class of the Request class, so your methods should work the same. I believe you need to call .post() or .get() at the end instead of send, but thats about all that should chnge. I'm not sure what version you're running on but here is the link tot he docs Mootools Request.JSONP

iangraham
A: 

What I ended up doing was just using an iframe. All I really had to do was send data to another site and not receive any so it worked out.

Tyler Johnson