Hi @JSolorzano I do nothing but POSTS, 24 x 7. The only time I Get is for specific commands. Here are the 2 UTIL functions I use.
/**
* Created by Jim on 6/11/14.
*/
(function( $ ){ //Sweetness Baby!!!! Thanks STACKOVERFLOW!!!! :)
$.myPost = function( url, data, context, success, error, timeout, sync ) {
var settings = {
type : "POST", //predefine request type to POST
'url' : url,
'data' : data,
'context': context,
'success' : success,
'error': error,
'timeout' : timeout,
'async' : sync
};
$.ajax(settings)
};
})(jQuery);
(function( $ ){ //Sweetness Baby!!!! Thanks STACKOVERFLOW!!!! :)
$.myGet = function( url, data, success, error, timeout ) {
var settings = {
type : GET, //predefine request type to POST
'url' : url,
'data' : data,
'success' : success,
'error': error,
'timeout' : timeout
};
$.ajax(settings)
};
})(jQuery);
I have a JS Class but it may be useless to you right now. The post call looks like this.
// how do we check the url is correct? timeout causes problems.
// the busy flag needs to be static for the class.
// make sure if callData is an object we make it an empty object.
// we do this so we can add _token to it.
if (callData == "") {
callData = {};
}
this.busy = true;
callData['_token'] = this.csrf_token;
fyi('Post... [' + url + ']');
$.myPost(url, callData, this, this.handlePost, this.postError, this.timeout, this.async);
};
handlePost is the js function called on success of the post call.
For Example:
function findPayload($p) {
var rec = $p[$p.rootName].Category[0];
app.setLongName(rec.Desc);
app.setShortName(rec.ShortName);
setCmdButton(UPDATE);
controlButtons();
}
function find(id) {
// We POST data to the backend, in place of URL data. For Flexibility.
var postData = {
id: id // Each entry is a separate _POST['id'] item on backend.
};
//debugger;
payLoad.setOnPayload(findPayload).call('find', postData);
}
The $p in find findPayload contains the JSON from the Controller. Its just a String at the end of the day.
The controller calls the Command to find the record and writes it back.
public function execFind($in)
{
$cmd = new GetCvgCategory();
$ret = $cmd->exec($in->id);
return $ret;
}
public function find()
{
if ($this->ping()) {
return "";
}
$in = new FindInputs();
//$_POST['id'] = 'd';
return $this->cmdExec($in, $_POST, 'execFind');
}
And the routes...
Route::post('find', 'CoverageCtrl@find');
Route::post('create', 'CoverageCtrl@create');
Route::post('update', 'CoverageCtrl@update');
Route::post('idx', 'CoverageCtrl@index');