Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ( $ ) {
- $.fn.ticket = function(options) {
- var opts = $.extend( {}, $.fn.ticket.defaults, options );
- return this.each(function() {
- var $this = $( this );
- $this.submit(function (e) {
- e.preventDefault();
- $.ajax({
- url : opts.url,
- dataType : 'json',
- crossDomain : true,
- beforeSend: function (xhr, opts) {
- xhr.setRequestHeader('Location-Api-Id', opts.location_api_id);
- xhr.setRequestHeader('Authorization', opts.key);
- },
- success : function (data) {
- $.fn.ticket.addTicket($this, data.ticket);
- }
- });
- });
- });
- };
- //adds a ticket to the form
- $.fn.ticket.addTicket = function (el, ticket) {
- el.append(ticket);
- }
- $.fn.ticket.defaults = {
- url : "default url"
- };
- }( jQuery ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement