huboo82
发表于 2012-3-2 15:13:55
本帖最后由 huboo82 于 2012-3-2 15:15 编辑
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
show.php 这个控制器上面多了一行。删掉就没问题了。{:soso_e101:}
pspman2
发表于 2012-3-2 15:20:31
huboo82 发表于 2012-3-2 15:13 static/image/common/back.gif
show.php 这个控制器上面多了一行。删掉就没问题了。
真的耶!!!!!:loveliness::loveliness::loveliness:太高兴了!!!谢谢,十分的谢谢,本来都打算不用ci的了,我又相信ci了
pspman2
发表于 2012-3-2 15:29:16
看来我还是初学者中的初学者啊,竟然连这种错误都会犯,真是让huboo82大神您见笑了
justdoit
发表于 2012-3-2 17:26:12
楼主,你把$.ajax方法先改成$post方式试一下,还不行的话,如果你愿意的话,把全部代码粘出来后,我帮你调试调试?
pspman2
发表于 2012-3-2 17:32:55
justdoit 发表于 2012-3-2 17:26 static/image/common/back.gif
楼主,你把$.ajax方法先改成$post方式试一下,还不行的话,如果你愿意的话,把全部代码粘出来后,我帮你调 ...
问题已解决了,谢谢!!
justdoit
发表于 2012-3-2 17:37:29
怎么回事?哪个地方的问题?
pspman2
发表于 2012-3-2 17:46:44
justdoit 发表于 2012-3-2 17:37 static/image/common/back.gif
怎么回事?哪个地方的问题?
是上面的控制器代码中多一段空行,导致输出结果多了个空行,data的返回数据有个空行(firebug查到)
现在又有一个问题困扰了我,请看代码(又是jquery的,我这方面真的很弱:'()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线视频网</title>
<base href="<?php echo base_url() ?>" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen, projection" />
<script src="js/jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var $div_li =$("div.tab_menu ul li");
$div_li.click(function(){
window.location.href="http://baidu.com/"+$(this).html()
})
$div_li.mouseover(function(){
$(this).addClass("selected") //当前<li>元素高亮
.siblings().removeClass("selected");//去掉其它同辈<li>元素的高亮
var index =$div_li.index(this);// 获取当前点击的<li>元素 在 全部li元素中的索引。
$show = $("div.tab_box > div"); //选取子节点。不选取子节点的话,会引起错误。如果里面还有div
$show.eq(index).fadeIn(500) //显示 <li>元素对应的<div>元素
.siblings().hide();
//隐藏其它几个同辈的<div>元素
}).hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
})
//----------用户验证-----------------------------------------------------
$('#zhuce').click(function(){
var bh = $("body").height();
var bw = $("body").width();
$("#fullbg").css({
height:bh,
width:bw,
display:"block"
});
$('.message').show();
//如果是必填的,则加红星标识.
$("form :input.required").each(function(){
var $required = $("<span class='high'> *</span>"); //创建元素
$(this).parent().append($required); //然后将它追加到文档中
});
//文本框失去焦点后
$('form :input').blur(function(){
var $parent = $(this).parent();
$parent.find(".formtips").remove();
//验证用户名
if( $(this).is('#user_name') ){
if( this.value=="" || this.value.length < 6 ){
$parent.append('<span class="formtips onError"></span>');
}else{
$.ajax({
type: "post",
url: "<?php echo site_url('show/usercheck') ?>",
datatype: "text",
data:"name="+$("#user_name").val(),
success: function(data){
console.log(data);
if(data=="2"){
message='hello';
$append = '<span class="formtips onSuccess">'+message+'</span>';
$parent.append($append);
}else{
$parent.append('<span class="formtips onError">'+data+'</span>');
}
}
});
}
}
//验证密码
if( $(this).is('#user_password') ){
if( this.value=="" ){
$parent.append('<span class="formtips onError"></span>');
}else{
$parent.append('<span class="formtips onSuccess"></span>');
}
}
//验证邮件
if( $(this).is('#email') ){
if( this.value=="" || ( this.value!="" && !/.+@.+.{2,4}$/.test(this.value) ) ){
$parent.append('<span class="formtips onError"></span>');
}else{
$parent.append('<span class="formtips onSuccess"></span>');
}
}
})
/*.keyup(function(){
$(this).triggerHandler("blur");
}).focus(function(){
$(this).triggerHandler("blur");
});//end blur
*/
//提交,最终验证。
$('#send').click(function(){
$("form :input.required").trigger('blur');
var numError = $('form .onError').length;
if(numError){
return false;
}
});
//重置
$('#res').click(function(){
$(".formtips").remove();
})
$('#close').click(function(){
$('form :input.required + span').remove();
$('.message,#fullbg').hide();
})
})
//移动
$("#gb").mousedown(function(e){
var offset = $(".message").offset();
var p = {top:offset.top - e.clientY,left:offset.left - e.clientX};
if (!e) e = window.event;
$(document).mousemove(function(e){
$("#gb").css("cursor","text");
$(".message").css({"top":e.clientY + p.top,"left":e.clientX + p.left,"position":"absolute"});
});
$(document).mouseup(function(){
$("#gb").css("cursor","move");
$(".message").css("position","fixed !important");
$(this).unbind("mousemove");
});
});
})
</script>
</head>
<body>
<div id="fullbg"></div>
<div class="message"><div class='sharp color6'><b class='b1'></b><b class='b2'></b><b class='b3'></b><b class='b4'></b><div class='content'><div style='text-align:right; cursor:move;' id='gb'><span style="cursor:pointer;" id='close'>关闭</span></div><div id='login' class='login'>用户注册</div><div style=' border:1px solid #999; width:190px;'></div><form action="<?php echo site_url('index/add/'); ?>" method='post'><ul><li><label for='user_name'>用户名:</label><input type='text' name='name' id='user_name' size='20' class='required' /></li><li><label for='user_password'>密码:</label><input type='password' name='password' id='user_password' size='20' class='required' /></li><li><label for='email'>邮箱:</label><input type='text' id='email' name='email'size='20' class='required' /></li><li id='sub'><br /><input type='submit' name='submit' id='send' class='bottom' value='提交' /><input type='reset' id='res' class='bottom' value='重置'/></li></ul></form></div><b class='b5'></b><b class='b6'></b><b class='b7'></b><b class='b8'></b></div></div>
<div id="head">
<div class="title">在线视频</div>
<div class="search">
<div style=" clear:both; margin-left:32px;"><form id="form1" name="form1" method="post" action="">
<ul><li><input name="search" id="search" type="text" size="21" maxlength="20" /></li><li> <select name="movie_type" >
<option value="全部" selected >全部</option>
<option value="电影">电影</option>
<option value="动漫">动漫</option>
</select></li><li> <input type="submit" name="submit"value=" "style="width:57px; height:24px; cursor:pointer; border:none; background-image:url(image/ico00000.gif)";/></li></ul>
</form>
</div>
</div>
</div>
<div class="main">
<!--左边框-->
<div class="left">
<?php
if($this->session->userdata('user_data')){
$this->load->view('login_ok_view');
}else{
$this->load->view('login_view');
}
?>
</div>
我用了个遮盖层,jquery方面是点‘close’后就隐藏那个用户注册的层,但,当我在打开这个层的是时候,ajax的用户验证就会请求两次,百思不得其解,希望你能给点意见。
lynn.wang
发表于 2012-3-3 11:55:20
首先. 函数返回值尽量不要用中文,检查函数改一下
function usercheck(){
if($this->Index_model->user_check()){
echo -1;
}
else{
echo 1;
}
}
-1表示存在
1表示不存在
再一个 ajax 中的 success 改一下
success: function(data){
if(data==1){
message='hello';
$append = '<span class="formtips onSuccess">'+message+'</span>'
$parent.append($append);
}else{
message='user exist';
$parent.append('<span class="formtips onError">'+message+'</span>');
}
}
这里可能是文件编码问题,造成返回值中文的话会造成乱码等也说不定
最后,用FireFox 的 Firebug 插件
很好用 熟悉下就知道用了
如果还出现什么问题
就show出来
一起探讨啊
pspman2
发表于 2012-3-3 12:04:39
lynn.wang 发表于 2012-3-3 11:55 static/image/common/back.gif
首先. 函数返回值尽量不要用中文,检查函数改一下
-1表示存在
多谢回复,该问题已解决,不过又有了个新的问题,在本贴的47楼,也不想另起一贴了,如果可以,希望大家研究一下
lynn.wang
发表于 2012-3-3 12:08:58
一般执行2次都是 jQuery 里面有什么地方有点小问题
这个还是比较难找的,因为他语法太简单了。。。
你还是贴个图说吧
一堆东西晃眼啊!!!