How does AJAX take and pass parameters to another page?

1. First operate on the current page

tableData.ChangeA = function (rowData) {
    window.location.href= "/adD?deptCode=" + rowData.deptId + '&month=' + rowData.month ; //window.location.href jump to new page
 } ;

2. Parse the link on another page

function parseUrl(url){
    var query = url.split("?")[1];
var queryArr = query.split("&");
var obj = {};
queryArr.forEach(function(item){
        var key = item.split("=")[0];
var value = item.split("=")[1];
obj[key] = decodeURIComponent                            (value) ;
     }) ;
 return obj ;
 }
 // information passed by
 url var urlMsg = parseUrl (window.location.search ) ;    

3. Analyze the parameters:

$.ajax({
    url:'/attend/getByDept?deptCode='+urlMsg.deptCode+'&month='+urlMsg.month,
method: 'get'
})    
.done(function (msg) {
})
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325483578&siteId=291194637