﻿
(function($) {
	$.webservice=function(options) {
		var defaults = {
			url: null,
		    command: "none",
		    data: null,
			success: null,
			error: null
		  };
		var op = $.extend(defaults, options);
		if (op.url==null) throw new Error("url is not prvided");
		if (op.command==null) throw new Error("command is not prvided");
		var data1="cmd="+op.command;
		if (op.data!=null) data1+="&"+op.data;
		data1+="&dt="+new Date();
		$.ajax({
		  type: "GET",
		  url: op.url,
		  data: data1,
		  success: function(data, textStatus) {
			if(op.success!=null) op.success(data);
		  },
		  error: function (XMLHttpRequest, textStatus, errorThrown) {
			if(op.error!=null) op.error(XMLHttpRequest.responseText);
		  }
		});		  
	}
})(jQuery);