Php 为什么我的搜索代码在internet explorer上不起作用
我有以下代码用于从数据库搜索显示返回结果到页面,并用jqgrid显示它们,我的代码在firefox上运行良好,但在ie上不起作用,当我使用utf8时 像阿拉伯字母一样,我将ie和firefox的编码都设置为unicode(utf8) 它的html代码Php 为什么我的搜索代码在internet explorer上不起作用,php,javascript,html,jqgrid,Php,Javascript,Html,Jqgrid,我有以下代码用于从数据库搜索显示返回结果到页面,并用jqgrid显示它们,我的代码在firefox上运行良好,但在ie上不起作用,当我使用utf8时 像阿拉伯字母一样,我将ie和firefox的编码都设置为unicode(utf8) 它的html代码 first name: <input type="text" id="firstname" onkeydown="doSearch(arguments[0]||event)" value="" class="mytextbox" />
first name: <input type="text" id="firstname" onkeydown="doSearch(arguments[0]||event)" value="" class="mytextbox" />
<button onclick="gridReload()" id="submitButton" style="margin-right:100px;" class="Buttons">search</button>
为什么它不适用于ie(我用ie8测试),而适用于opera和firefox
谢谢首先,您对使用
setGridParam
的行中的引号有问题。也许你是说
jQuery("#list2").jqGrid('setGridParam',
{url:"<?php bloginfo('template_url'); ?>/post2.php?firstname="+firstname,
page:1}).trigger("reloadGrid");
jQuery(#list2”).jqGrid('setGridParam',
{url:“/post2.php?firstname=“+firstname,
页面:1}).触发器(“重新加载网格”);
而不是
jQuery("#list2").jqGrid('setGridParam',
{url:"<?php bloginfo('template_url'); ?>/post2.php?firstname="+firstname",
page:1}).trigger("reloadGrid");
jQuery(#list2”).jqGrid('setGridParam',
{url:“/post2.php?firstname=“+firstname”,
页面:1}).触发器(“重新加载网格”);
在我看来,用这段代码构建url不太好。你至少应该使用
jQuery("#list2").jqGrid('setGridParam',
{url:"<?php bloginfo('template_url'); ?>/post2.php?firstname="
+encodeURIComponent(firstname),
page:1}).trigger("reloadGrid");
jQuery(#list2”).jqGrid('setGridParam',
{url:“/post2.php?firstname=”
+编码组件(名字),
页面:1}).触发器(“重新加载网格”);
或
jQuery(#list2”).jqGrid('setGridParam',
{url:“/post2.php?”+
param({firstname:firstname}),
页面:1}).触发器(“重新加载网格”);
然后,firstname
中的任何国际字符都将在url中正确编码
还有一种方法是使用jqGrid的
postData
参数。例如,请参见。Define“works”vs“not work”。在IE的情况下,您会得到什么意外的输出?在IE上它没有找到记录,但在firefox上它找到了我的搜索记录并在jqGrid上显示感谢您的回复,我的问题通过jQuery.param函数得到了解决
jQuery("#list2").jqGrid('setGridParam',
{url:"<?php bloginfo('template_url'); ?>/post2.php?firstname="+firstname",
page:1}).trigger("reloadGrid");
jQuery("#list2").jqGrid('setGridParam',
{url:"<?php bloginfo('template_url'); ?>/post2.php?firstname="
+encodeURIComponent(firstname),
page:1}).trigger("reloadGrid");
jQuery("#list2").jqGrid('setGridParam',
{url:"<?php bloginfo('template_url'); ?>/post2.php?"+
jQuery.param({firstname: firstname}),
page:1}).trigger("reloadGrid");