Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Wednesday, 25 June 2014

Number Formatting Using JavaScript

Tested Approach:
number.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');Short solution #2:

Alternate Solution:
number.toFixed(2).replace(/./g, function(c, i, a) {
return i && c !== "." && !((a.length - i) % 3) ? ',' + c : c;
});

Example:
5543.45 will be converted to 5,543.45.

Wednesday, 14 May 2014

JavaScript/Ajax file upload with Jquery iframe post

Demo code
<script type="text/javascript" src="jQueryAjaxUpload.js"></script>

<form method="post" action="" enctype="multipart/form-data" id="example_form">
<input type="file" name="file"/>
<input type="submit"/>
</form>
<script>

$('#example_form').ajaxUpload({

post :
function (){

alert('posted');
},


complete :
function() {

alert('Upload complete');
}


});
</script> In case of using spring add below bean to spring beans
<bean id="multipartResolver"

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<!-- one of the properties available; the maximum file size in bytes -->

<property name="maxUploadSize" value="1000000"/>
</bean>
 Follow the below link to download jQueryAjaxUpload.js file

http://www.jainaewen.com/files/javascript/jquery/iframe-post-form.html

Run Postman API remote or code or command line

POSTMAN is used to run the APIs generally. What if we want to create a collection in postman and run it from some other code or command l...