English 中文(简体)
代码 - 发送 jQuery 日志日志数据后无结果
原标题:Codeigniter - No result after sending jQuery post data

我正在用 jQuery s AJAX 和 Cocigniter PHP 框架编写签名表,但编码员并不重要,如果你看到怪异的echo form_open (); 或其他怪事,别担心,它们都是编码员。

我用下面的jquery(在php代码中, 其它所有东西都被省略了, 并添加了一个简单的回声问候, 世界! ; 功能, 和它的工作方式/ 向我问好, 世界! ) :

 $.post(  ajax_signup_username  ,function(result){

                $(span_error).html(result);

            } );

但当我通过其中的一个日志数据时,它不起作用( doesn t 输出任何结果, 注意我使用的是 < number> full PHP 代码 书面的 < em> below- below ):

$.post(  ajax_signup_username , {php_username_error:username_value} ,function(result){

                $(span_error).html(result);

            } );

我尝试了搜索SO,但所提供的解决方案没有解决这个问题。知道什么是错的吗?

<强> 这是完整的代码:

以下是 html 代码 :

<body>

<?php $attr = array(  onsubmit  =>  return final_val()  ); echo form_open( formValidation/signUp ,$attr); ?>


<p>Username: <input type="text" onBlur="username_val()" value="<?php echo set_value( username )?>" name="username" maxlength="50" /><span name="username_error"><?php echo form_error( username ); ?></p></span>


<p>Email: <input type="text" onBlur="email_val()" value="<?php echo set_value( email )?>" name="email" maxlength="50" /><span name="email_error"><?php echo form_error( email ); ?></p></span>


<p>Password: <input type="password" onBlur="pass_val()" value="<?php echo set_value( pass )?>" name="pass" maxlength="50" autocomplete="off"/><span name="pass_error"><?php echo form_error( pass ); ?></p></span>


<p>Password Confirm: <input type="password" onBlur="pass_val()" value="<?php echo set_value( passconf )?>" name="passconf" maxlength="50" autocomplete="off" /><span name="passconf_error"><?php echo form_error( passconf ); ?></p></span>



<p><input type="submit" value="SIGN UP!" name="signup"/></p>


</form>



</body>

以下是php代码:

function ajax_signup_username(){

    $username = $_POST[ php_username_error ];

    $uniqueUn = $this->db->prepare("SELECT * FROM iowfiwefwmember WHERE username=:username");

    $uniqueUn->bindParam( :username , $username);

    $uniqueUn->execute();

    $count1 = $uniqueUn->fetch();

    if( $count1 == FALSE ){

        echo  USERNAME AVAILABLE! ;

    }else{

        echo  USERNAME IS ALREADY USED! ;

    }

}

以下为注解代码:

function username_val(){

        $.ajaxSetup({ cache : false });

            username_value = $("input[name= username ]").val();

            span_error = "span[name= username_error ]";

            //$(span_error).load( ajax_signup_username , {php_username_error:username_value}); <-- also doesn t work [ $.ajaxSetup() is set to POST ]

            $.post(  ajax_signup_username , {php_username_error:username_value} ,function(result){

                $(span_error).html(result);

            } );

    }
最佳回答

在我笔记本电脑前做长时间的哑脸之后,我发现这个IS 是一个代码问题,我打开了引起问题的CSRF保护程序。关闭了CSRF的功能后,效果很好,确保不要重复同样的错误,年轻人! 干杯! : D :

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签