How to transfer parameters flexibly to post parameters of jquery

 5 install  
{ "addon_id": data.id }{ "addon_title": data.title }
5  
Dec.30,2021

if all other steps are the same

//
function x_request(params){
    $.post('url',params,function....)

}
//
X_request({ 'addon_id': data.id })
X_request({ 'addon_title': data.title })

function postSomething(payload) {
    ...
    $.post('{...}', payload, function(data) { 
    ...
}

postSomething({ 'addon_id': data.id })
postSomething({ 'addon_title': data.title })

Network layer

first propose a network tool that calls this method whenever it is a network request. At the same time, it can also encapsulate get , push and other methods

.
function post(url, data, success, failure)
  • address to be accessed by url:
  • data to be sent by data:
  • success: callback is successful
  • failure: failed callback

model layer

package another model

function installModel(data, success, failure){
    post('.../install',data, success, failure)
}

View layer

Last view layer call

table.on("...", function(){
    installModal(data, function success(){...}, function failure(){...})
})

   //
    function x_request(event, params) {
        switch (event) {
            case 'install':
                $.post('url', params, xxxx);
                break;
            case 'xxx':
                $.post('url', params, xxxx);
                break;
                
        }
    }
    //
    X_request(obj.event,{ 'addon_id': data.id })
    X_request(obj.event,{ 'addon_title': data.title })
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36fa1-2c03c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36fa1-2c03c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?