THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
No Formatcode |
---|
actions: {
add: {
createForm: {...},
action: function(args) {
$.ajax({
// To generate a URL, use createURL, with the API command as a string arg
url: createURL('addNexusVswitch'), // Or whatever the API command is to add a vswitch,
data: {
// Key is the param that the api accepts, the value is
// args.data.[createForm ID] -- so here, our API wants a
// param named 'ipaddress,' and above we named our
// createForm field 'ipAddress,' whose value is passed in
// our args as args.data.ipAddress
ipaddress: args.data.ipAddress,
// Similar format for the remaining input fields
username: args.data.user,
password: args.data.password
},
// If this is a async action (i.e., job-queued), then on
// successful validation the API will return a job ID, which
// you pass through the widget when you call the 'success'
// callback
//
// -- this is then given to the 'poll' function below
// (pollAsyncJobResult)
success: function(json) {
args.response.success({
// Use firebug debugger to determine what to use to get the job id
_custom: { jobId: json.addnexusvswitchresponse.jobid }
});
},
// If the server returns an error. I.e., problem with input
// validation. The format is almost always the same for all
// actions, so you can use this for any other actions you need
error: function(json) {
args.response.error(parseXMLHttpResponse(json));
}
});
},
// You almost always format the notification.poll like this for all actions
// -- pollAsyncJobResult does most of the work for you
notification: {
poll: pollAsyncJobResult
},
messages: { ... }
}
}
|