急!!php页面加载不完全的问题,在线等
PHP
RT,同一个页面多次刷新,有时候正常,有时候只显示一半,有时候则完全空白完全的页面
一半
本机调试的时候没有遇到此问题,这是在外网发布的时候发生的。下拉框中的内容是用fopen打开了一个.tab文件然后读取出来的,然后通过循环转成数组,又通过循环给js数组赋值,循环为1000。
设置了set_time_limit(60*60*10)依然无效。。。
跪求指导,谢谢。。。附上部分代码
common.php<?phppublic static function readTabFile($fileName) { if (!file_exists($fileName)) { die("<b>404 File not found!</b>"); } $handle = fopen($fileName, 'rb'); $contents = fread($handle, filesize ($fileName)); //iconv("UTF-8","GBK", $contents); if(ord($contents) == 0xEF) { $contents = substr($contents, 4); } $rows = explode("\r\n", $contents); fclose($handle); $ret; $colNames = null; for($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; if(!empty($row) && $row != "" && substr($row, 0, 1) != "#") { $col = explode("\t", $row); if(empty($colNames) || $colNames == null) $colNames = $col; else { $item; $itemId = (int)$col[0]; if(empty($itemId)) { die("..."); } for($j = 0; $j < count($col); $j++) { $value = $col[$j]; $item[$colNames[$j]] = $value; } $ret[$itemId] = $item; } } } return $ret; }?>test.php<?php $dir = "../goods.tab"; $table = Common::readTabFile($dir);?><script> var goodsTb = new Array(); <?php foreach($table as $key => $value) { echo "goodsTb[".$value["id"]."]=\"".iconv("GBK","UTF-8", $value["sz_name"])."\";"; } ?> function checkNum(i) { var sle_obj = document.getElementById('valueType' + i); var index = sle_obj.selectedIndex; var valueType = sle_obj.options[index].value; var num_obj = document.getElementById('count' + i); if(valueType == -1) { alert('请选择道具类型!'); } if(num_obj.value > 500) num_obj.value = 500; } var i = 1; function addFile() { var dv = document.getElementById("dvFiles"); var selectObj = document.createElement("select"); selectObj.name = "valueType"; selectObj.id = "valueType" + i; var sg = document.createTextNode("选择道具 "); dv.appendChild(sg); //创建select选项卡 var myOption = document.createElement("option"); myOption.setAttribute("value","-1"); myOption.appendChild(document.createTextNode("无")); selectObj.appendChild(myOption); for (var key in goodsTb) { var op = document.createElement("option"); op.setAttribute("value", key); op.appendChild(document.createTextNode(goodsTb[key])); selectObj.appendChild(op); } dv.appendChild(selectObj);....
回复讨论(解决方案)
跪求啊|!!
在线等,呜呜呜呜
管管啊
有时候正常大致可认为代码没问题
完全空白是什么意思?整个页面没一个字?
这多数是网络的问题,和代码没太大关系,除非是你的程序算法太复杂导致在浏览器超时范围内都没有响应
就是一个字都没有,空白。。。
算法也不复杂吧。。。就2个1000的循环而已,代码我也贴出来了。。。
但是肯定是跟网络有关,本地调试都是正常的。。。
空白的原因是因为js里面有个循环,执行js到一半就停止了。。。求方案
空白的原因是因为js里面有个循环,执行js到一半就停止了。。。求方案
可能是js性能问题.
强烈建议用php做循环.比如使用smarty模板,将数组传给显示模板,在里边循环 然后将循环得到的html返回或者输出前台
不要用js循环了
空白的原因是因为js里面有个循环,执行js到一半就停止了。。。求方案
可能是js性能问题.
强烈建议用php做循环.比如使用smarty模板,将数组传给显示模板,在里边循环 然后将循环得到的html返回或者输出前台
不要用js循环了
对js不是很懂- -,但是从ff页面执行源码来看,确实是前段的代码没执行完,php拿出来的数组是正确的,就是在输出js的时候停止了。
没有了解过smarty模板,请问js有解决办法吗
换了中方法,直接用php来输出js也不行。。。感觉老是输出不完全。。。
还有一种可能就是服务器的内存大小限制会有这个影响。
空白的原因是因为js里面有个循环,执行js到一半就停止了。。。求方案
可能是js性能问题.
强烈建议用php做循环.比如使用smarty模板,将数组传给显示模板,在里边循环 然后将循环得到的html返回或者输出前台
不要用js循环了
对js不是很懂- -,但是从ff页面执行源码来看,确实是前段的代码没执行完,php拿出来的数组是正确的,就是在输出js的时候停止了。
没有了解过smarty模板,请问js有解决办法吗
我觉得JS肯定有解决和优化的办法
不过我这里提不出来
我只能建议用PHP来做循环.
如果不懂smarty也没关系 就直接在php里循环 ,用echo来拼出html
为啥非得用js来循环和组合呢
echo $str; foreach($table as $key => $value) { echo 'var op = document.createElement(\"option\");'; echo 'op.setAttribute(\"value\", "'.$value["id"].'");'; echo 'op.appendChild(document.createTextNode("'.iconv("GBK","UTF-8", $value["sz_name"]).'"));'; echo 'selectObj.appendChild(op)'; } ?>
用php来输出Html还是不行。。。。。。。。。。。
汗 你这个用php来输出了一堆js语句....
用PHP直接输出html不行吗.......
大概看了下你的页面最多就是几个有关联的select列表 可能还有ajax去后台取数据 php输出html+js提交查询和选择 完全可以实现 何必每一行都是js代码呢
大概看了下你的页面最多就是几个有关联的select列表 可能还有ajax去后台取数据 php输出html+js提交查询和选择 完全可以实现 何必每一行都是js代码呢
第一个下拉框就是php直接输出的html的,但是有个添加按钮,每点一次都会产生一个新的下拉框。。。。目前添加按钮用的Js实现的
大概看了下你的页面最多就是几个有关联的select列表 可能还有ajax去后台取数据 php输出html+js提交查询和选择 完全可以实现 何必每一行都是js代码呢
第一个下拉框就是php直接输出的html的,但是有个添加按钮,每点一次都会产生一个新的下拉框。。。。目前添加按钮用的Js实现的
点添加又出现一个选择道具物品的下拉框对吗?
和上一个有区别吗?
没有区别就直接将其html插入到上一个下拉单所在的div下方就可以了
假设第一个下拉框的class=abc,下拉框和后边的输入框在同一个div下
$(".abc").parent().after($(".abc").parent().html());
jquery一句话就实现了
怎么说呢业务细节越细我这边就没法说更多了因为不了解
其实我的意思归根结底就是完全没必要使用复杂的js循环导致页面都显示不完 很多方法可以实现的
好吧,用jquery真的很简单- -
请问 $(".abc").after($(".abc").html()); 可以修改后面赋值内容的id跟name么
你是不是用了什么第三方的模板插件呐,一般引起这问题是因为模板内部缓存功能
好吧,用jquery真的很简单- -
请问 $(".abc").after($(".abc").html()); 可以修改后面赋值内容的id跟name么
当然可以 这是另一个问题
看你的这个select列表的结构和你js文件的写法了
比如你给每一项定义一个自定义属性比如说叫val="id1234"
然后当你选择某一项时 用js获取选择项的这个val和中间的text描述
然后存入后边的input的value中 (用jquery选择器会很方便)
这是js比较简单的应用了.
你是不是用了什么第三方的模板插件呐,一般引起这问题是因为模板内部缓存功能
什么插件都没用。。。
好吧,用jquery真的很简单- -
请问 $(".abc").after($(".abc").html()); 可以修改后面赋值内容的id跟name么
当然可以 这是另一个问题
看你的这个select列表的结构和你js文件的写法了
比如你给每一项定义一个自定义属性比如说叫val="id1234"
然后当你选择某一项时 用js获取选择项的这个val和中间的text描述
然后存入后边的input的value中 (用jquery选择器会很方便)
这是js比较简单的应用了.
jquery没有用过,只是参考文档能了解些语法。。。
我最早贴的图,就是我选择了物品后,需要填写数量,就是一个select跟一个text,
点击添加后,$(".abc").after($(".abc").html())这种方法,会导致select,text的id跟原来的一样,我想区分开来,比如用个变量i控制,每添加一个i就加1.。。
另外我想添加的项后面可以跟个删除按钮,点击删除可以删除本项,麻烦给个代码示例参考下,谢谢- -
好吧,用jquery真的很简单- -
请问 $(".abc").after($(".abc").html()); 可以修改后面赋值内容的id跟name么
当然可以 这是另一个问题
看你的这个select列表的结构和你js文件的写法了
比如你给每一项定义一个自定义属性比如说叫val="id1234"
然后当你选择某一项时 用js获取选择项的这个val和中间的text描述
然后存入后边的input的value中 (用jquery选择器会很方便)
这是js比较简单的应用了.
jquery没有用过,只是参考文档能了解些语法。。。
我最早贴的图,就是我选择了物品后,需要填写数量,就是一个select跟一个text,
点击添加后,$(".abc").after($(".abc").html())这种方法,会导致select,text的id跟原来的一样,我想区分开来,比如用个变量i控制,每添加一个i就加1.。。
另外我想添加的项后面可以跟个删除按钮,点击删除可以删除本项,麻烦给个代码示例参考下,谢谢- -
抱歉才到家.
写了个简单的demo,只有增加和删除DIV的 选择后写入值的可以去网上搜下相关文章
<!doctype html><html lang="cn"><head> <meta charset="UTF-8"> <title>Document</title> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function addDiv(){ var lastHtml = $(".abc:last").clone(); var item_id = $(".abc:last select").attr("id"); var input_id = $(".abc:last input").attr("id"); var new_item_id = "item_" + (parseInt(item_id.substr(5))+1); var new_input_id = "item_num_" + (parseInt(input_id.substr(9))+1); lastHtml.children("select").attr("name",new_item_id); lastHtml.children("select").attr("id",new_item_id); lastHtml.children("input").attr("name",new_input_id); lastHtml.children("input").attr("id",new_input_id); $(".abc:last").after("<div class='abc'>"+lastHtml.html()+"</div>"); } function delDiv(obj){ var i = $(".abc").length; if (i>1) { $(obj).parent(".abc").remove(); }else{ alert("至少选择一项"); } } </script></head><body> <div><!--以后换成form--> <div class="abc"> <select name="item_1" id="item_1" > <option value="0">无</option> <option value="1">剑气火灵幻影</option> <option value="2">神武至尊怒火</option> <option value="3">鬼舞玄冰法杖</option> </select> 数量 <input type="text" name="item_num_1" id="item_num_1" value="" /> <a href="javascript:void(0)" onclick="delDiv(this)">删除</a> </div> <button onClick = "addDiv()">添加</button> </div></body></html>
欢迎继续交流啊
好吧,用jquery真的很简单- -
请问 $(".abc").after($(".abc").html()); 可以修改后面赋值内容的id跟name么
当然可以 这是另一个问题
看你的这个select列表的结构和你js文件的写法了
比如你给每一项定义一个自定义属性比如说叫val="id1234"
然后当你选择某一项时 用js获取选择项的这个val和中间的text描述
然后存入后边的input的value中 (用jquery选择器会很方便)
这是js比较简单的应用了.
jquery没有用过,只是参考文档能了解些语法。。。
我最早贴的图,就是我选择了物品后,需要填写数量,就是一个select跟一个text,
点击添加后,$(".abc").after($(".abc").html())这种方法,会导致select,text的id跟原来的一样,我想区分开来,比如用个变量i控制,每添加一个i就加1.。。
另外我想添加的项后面可以跟个删除按钮,点击删除可以删除本项,麻烦给个代码示例参考下,谢谢- -
抱歉才到家.
写了个简单的demo,只有增加和删除DIV的 选择后写入值的可以去网上搜下相关文章
<!doctype html><html lang="cn"><head> <meta charset="UTF-8"> <title>Document</title> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function addDiv(){ var lastHtml = $(".abc:last").clone(); var item_id = $(".abc:last select").attr("id"); var input_id = $(".abc:last input").attr("id"); var new_item_id = "item_" + (parseInt(item_id.substr(5))+1); var new_input_id = "item_num_" + (parseInt(input_id.substr(9))+1); lastHtml.children("select").attr("name",new_item_id); lastHtml.children("select").attr("id",new_item_id); lastHtml.children("input").attr("name",new_input_id); lastHtml.children("input").attr("id",new_input_id); $(".abc:last").after("<div class='abc'>"+lastHtml.html()+"</div>"); } function delDiv(obj){ var i = $(".abc").length; if (i>1) { $(obj).parent(".abc").remove(); }else{ alert("至少选择一项"); } } </script></head><body> <div><!--以后换成form--> <div class="abc"> <select name="item_1" id="item_1" > <option value="0">无</option> <option value="1">剑气火灵幻影</option> <option value="2">神武至尊怒火</option> <option value="3">鬼舞玄冰法杖</option> </select> 数量 <input type="text" name="item_num_1" id="item_num_1" value="" /> <a href="javascript:void(0)" onclick="delDiv(this)">删除</a> </div> <button onClick = "addDiv()">添加</button> </div></body></html>
欢迎继续交流啊 非常感谢,结贴!
交个朋友- -
都是新手 多交流
给你个小思路 看能帮到你不!
test.php<?php $dir = "../goods.tab"; $table = Common::readTabFile($dir); foreach($table as $key => $value) { echo "<option value='{$value["id"]}'>".iconv("GBK","UTF-8", $value["sz_name"])."</option>"; }?>test.html //加载jquery<select id="tools" name="tools[]"></select><a href="javascript:addTools();"></a><script>function autoTools(){ var i=$("#tools").length-1;$.get("test.php",function(data){$("#tools:eq("+i+")").html(data);});}function addTools(){ $("#tools").after("<select id='tools' name='tools[]'></select>").autoTools();}autoTools();</script>
好吧,用jquery真的很简单- -
请问 $(".abc").after($(".abc").html()); 可以修改后面赋值内容的id跟name么
当然可以 这是另一个问题
看你的这个select列表的结构和你js文件的写法了
比如你给每一项定义一个自定义属性比如说叫val="id1234"
然后当你选择某一项时 用js获取选择项的这个val和中间的text描述
然后存入后边的input的value中 (用jquery选择器会很方便)
这是js比较简单的应用了.
jquery没有用过,只是参考文档能了解些语法。。。
我最早贴的图,就是我选择了物品后,需要填写数量,就是一个select跟一个text,
点击添加后,$(".abc").after($(".abc").html())这种方法,会导致select,text的id跟原来的一样,我想区分开来,比如用个变量i控制,每添加一个i就加1.。。
另外我想添加的项后面可以跟个删除按钮,点击删除可以删除本项,麻烦给个代码示例参考下,谢谢- -
抱歉才到家.
写了个简单的demo,只有增加和删除DIV的 选择后写入值的可以去网上搜下相关文章
<!doctype html><html lang="cn"><head> <meta charset="UTF-8"> <title>Document</title> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function addDiv(){ var lastHtml = $(".abc:last").clone(); var item_id = $(".abc:last select").attr("id"); var input_id = $(".abc:last input").attr("id"); var new_item_id = "item_" + (parseInt(item_id.substr(5))+1); var new_input_id = "item_num_" + (parseInt(input_id.substr(9))+1); lastHtml.children("select").attr("name",new_item_id); lastHtml.children("select").attr("id",new_item_id); lastHtml.children("input").attr("name",new_input_id); lastHtml.children("input").attr("id",new_input_id); $(".abc:last").after("<div class='abc'>"+lastHtml.html()+"</div>"); } function delDiv(obj){ var i = $(".abc").length; if (i>1) { $(obj).parent(".abc").remove(); }else{ alert("至少选择一项"); } } </script></head><body> <div><!--以后换成form--> <div class="abc"> <select name="item_1" id="item_1" > <option value="0">无</option> <option value="1">剑气火灵幻影</option> <option value="2">神武至尊怒火</option> <option value="3">鬼舞玄冰法杖</option> </select> 数量 <input type="text" name="item_num_1" id="item_num_1" value="" /> <a href="javascript:void(0)" onclick="delDiv(this)">删除</a> </div> <button onClick = "addDiv()">添加</button> </div></body></html>
欢迎继续交流啊 非常感谢,结贴!
交个朋友- - 哥们在吗?问个问题
大概看了下你的页面最多就是几个有关联的select列表 可能还有ajax去后台取数据 php输出html+js提交查询和选择 完全可以实现 何必每一行都是js代码呢
第一个下拉框就是php直接输出的html的,但是有个添加按钮,每点一次都会产生一个新的下拉框。。。。目前添加按钮用的Js实现的
点添加又出现一个选择道具物品的下拉框对吗?
和上一个有区别吗?
没有区别就直接将其html插入到上一个下拉单所在的div下方就可以了
假设第一个下拉框的class=abc,下拉框和后边的输入框在同一个div下
$(".abc").parent().after($(".abc").parent().html());
jquery一句话就实现了
怎么说呢业务细节越细我这边就没法说更多了因为不了解
其实我的意思归根结底就是完全没必要使用复杂的js循环导致页面都显示不完 很多方法可以实现的 。。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
