Monthly Archives: April 2014

Refresh a Page with JavaScript

Hey everyone,

Just a quick post on how to force a page refresh with JavaScript (no jQuery required):

location.reload();

Note that the reload function accepts a boolean parameter that can be used for force a server refresh. Alternatively, it just defaults to the cache.

Checkout this Stackoverflow post for more info: http://stackoverflow.com/a/5404869/522859

Detecting File Size with jQuery

Detecting FileSize – jQuery

Hey everyone,

Just a quick post on how to detect a file’s size with jQuery. I’m currently using a version of this for basic client side validation:

<form action="upload" enctype="multipart/form-data" method="post">
 
    Upload image:
    <input id="image-file" type="file" name="file" />
</form>
$(document).ready(function(){
    $('#image-file').bind('change', function() {
 
        var fileSize = this.files && this.files.length > 0 && this.files[0].size ? this.files[0].size / 1024 / 1024 : 0;
 
        if(fileSize > 0){
            $('body').append('<div class="file valid">' + fileSize + ' MB</div>');  
        }
        else{
            $('body').append('<div class="file invalid">' + fileSize + ' MB</div>'); 
        }            
    });
});
.file{
padding: 5px 7px;
border-radius: 3px;
background-color: green;
color: white;
margin: 5px;
}
 
.file.valid{
background-color: rgb(127, 197, 127);
}
 
.file.invalid{
background-color: rgb(197, 127, 127);
}

Here’s the link to the full fiddle: http://jsfiddle.net/nLLMF/

There’re also a whole heap of other options listed on this StackOverflow post if you’re chasing something a bit more robust: http://stackoverflow.com/a/13249924/522859

Request for ConfigurationPermission failed while attempting to access configuration section ‘paypal’ – PayPal & GoDaddy

Hey everyone,

I ran into the following error today while working with PayPal on a GoDaddy hosted server:

Request for ConfigurationPermission failed while attempting to access configuration section ‘paypal’. To allow all callers to access the data for this section, set section attribute ‘requirePermission’ equal ‘false’ in the configuration file where this section is declared.

To fix it, all you need to do is add the requirePermission attribute to the section declaration. Note that this is not where it says paypal but under the configsections heading.

<configSections>
    <!-- here -->
    <section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK" requirePermission="false"></section>
</configSections>

My Selling Tools Option Missing – PayPal

Hey everyone,

For some reason the “My Selling Tools” option is now missing on my production account. Unfortunately the only way to get around this that I’ve come across is to access the required features directly. For example:

API Access:
https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-api-access

If you’ve got any other links that might be useful please let me know and I’ll add them.