又发现一神奇现象!实在无解。。。求助大神!
截图中的代码是视频里的老师写的源码,但问题来了!
明明可以alert出整体的url,但是get请求?号后的第一个参数竟然消失了
这是为啥啊?莫非,get请求中,?(问号)后面一个参数不算get 请求?
1
收起
正在回答 回答被采纳积分+1
2回答
轩辕小齐V
2019-03-18 19:35:01
// $(document).ready(); //默认当前页面 let pageNo = 1; // 公用关键字 let kws = ''; //获取到搜索按钮 let searchBtn = document.getElementById('search_btn'); //当触发点击搜索 searchBtn.onclick = function () { alert("进来了"); let searchInput = document.getElementById('exampleInputName2'); let keywords = searchInput.value; //调用请求数据 requestData(pageNo, keywords); }; let requestPage = function(page) { requestData(page, kws); pageNo = page; }; requestData = function (page_num, page_kws) { //获取展示div let content_body = document.getElementsByClassName('row')[0]; let pagination = document.getElementsByClassName('pagination')[0]; // content_body.innerHTML = '<div class="text-center"><i class="fa fa-spinner fa-spin" style="font-size:24px"></i> 加载中...</div>'; //ajax 请求数据 $.get('index.php', {"page":page_num, "search": page_kws}, function (res) { let divs = ''; if (res.code == 1) { res.rows.forEach(function (item) { let div = ' <div class="col-sm-6 col-md-3 col-lg-4 ">' + '<div class="image">' + '<a href="#" target="_blank"><img class="img-responsive" src='+item.image_path+'></a>' + '<div class="caption">' + '<p>' + item.image_des+ ' </p>' + '</div>' + '</div>' + '</div>'; divs += div; }); } content_body.innerHTML = divs; // 加载分页 let home = ''; let previousBtn =''; let nextBtn = ''; let end = ''; // home previous if (res.page_num == 1) { home = '<li class="page-item disabled"><a class="page-link" href="javascript:requestPage(1);">Home</a></li>'; previousBtn = '<li class="page-item disabled"><a class="page-link" href="javascript:requestPage(' + (res.page_num - 1) + ');">Previous</a></li>'; } else { home = '<li class="page-item "><a class="page-link" href="javascript:requestPage(1);">home</a></li>'; previousBtn = '<li class="page-item"><a class="page-link" href="javascript:requestPage(' + (res.page_num - 1) + ');">Previous</a></li>'; } // next end if (res.page_total == res.page_num) { nextBtn = '<li class="page-item disabled"><a class="page-link" href="javascript:requestPage(' + (res.page_num + 1) + ');">Next</a></li>'; end = '<li class="page-item disabled"><a class="page-link" href="javascript:requestPage(' + res.page_total + ');">End</a></li>'; } else { nextBtn = '<li class="page-item"><a class="page-link" href="javascript:requestPage(' + (res.page_num + 1) + ');">Next</a></li>'; end = '<li class="page-item"><a class="page-link" href="javascript:requestPage(' + res.page_total + ');">End</a></li>' } let pages = home + previousBtn; for (let page = 1; page <= res.page_total; page++) { let active = ''; if (page == res.page_num) { active = 'active'; } pages += '<li class="page-item ' + active + '"><a class="page-link" href="javascript:requestPage(' + page + ');">' + page + '</a></li>'; } pages += nextBtn + end ; pagination.innerHTML = pages; },'json'); }; requestData(1, '');
老师这是js代码部分
PHP常用技术与ThinkPHP5框架开发
- 参与学习 人
- 提交作业 225 份
- 解答问题 3372 个
掌握用PHP开发互联网网站的必备功能,掌握当下主流的Linux系统开发,并熟练使用热门框架ThinkPhp开发电商团购项目,是通向PHP工程师必经之路。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星