Skip to content

Instantly share code, notes, and snippets.

@Tim-Machine
Created October 8, 2013 01:46
Show Gist options
  • Select an option

  • Save Tim-Machine/6878131 to your computer and use it in GitHub Desktop.

Select an option

Save Tim-Machine/6878131 to your computer and use it in GitHub Desktop.
setMessage = function(selector , message){
$(selector).html("");//clear html
$(selector).html(message);// insert message
}
makerequest = function(url , data , callback, type){
$.ajax({
url: url,
data: data,
type: type
}).done(function(somedata) {
// is call back a function?
if (callback && typeof(callback) === "function") {
callback(data); //send to callback funtion
}else
return data;
});
}
myfunction = function(){
$data = makerequest('www.com', {name:'ted',name:'test'} , null , 'POST');
setMessage('#message1', $data[0]);
}
myfuction()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment