Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在codeigniter表单验证中使用post()jquery方法_Php_Jquery_Codeigniter - Fatal编程技术网

Php 如何在codeigniter表单验证中使用post()jquery方法

Php 如何在codeigniter表单验证中使用post()jquery方法,php,jquery,codeigniter,Php,Jquery,Codeigniter,我想使用.post()jQuery方法在不刷新页面的情况下验证表单 我使用codeigniter进行验证。你能告诉我怎么做吗?我觉得很困惑 以下是jQuery代码: $(文档).ready(函数(){ $(“.form_errors”).hide(); $(“#发送”)。在(“单击”,function(){//提交按钮的id为=“发送” $(“.form_errors”).hide();//这些是显示错误的每个输入的 var user=$(“input.box”); 变量数据={}; 变量名称=

我想使用
.post()
jQuery方法在不刷新页面的情况下验证表单

我使用codeigniter进行验证。你能告诉我怎么做吗?我觉得很困惑

以下是jQuery代码:

$(文档).ready(函数(){
$(“.form_errors”).hide();
$(“#发送”)。在(“单击”,function(){//提交按钮的id为=“发送”
$(“.form_errors”).hide();//这些是显示错误的每个输入的
var user=$(“input.box”);
变量数据={};
变量名称=$(“input.box”).attr(“名称”);
对于(i=0;i,以下是我所做的

您必须使用Ajax来获取数据,而无需刷新页面

HTML页面

$form = $(form);
var url = $form.attr('action');
dataString = $form.serialize();
$.ajax({
type: "POST",
url: url,
data: dataString,
dataType: "json",
success: function(data) {
$(data).each(function(j,details){
var status = details.status;
var message = details.message;
$('#message_ajax_register').show();
$('#message_ajax_register').html('<div class="alert alert-success">'+message+'</div>');
});
}
});//end of $.ajax**   

如果条件
run(“'account”)
将这两个单引号替换为一个双引号,则PHP中存在错误。如果上述答案有用,则将其标记为有用,以便其他人可以使用。谢谢。不幸的是,我不经常使用stackoverflow,并且我没有足够的信誉点将其标记为有用。
    public function update_fest()
    {

        if($this->input->post())
        {
        $this->form_validation->set_rules('txtgpluswebsite', 'Google Plus Page URL', 'trim|xss_clean|prep_url');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

        if($this->form_validation->run() == false){
            $message = validation_errors();
            $data = array('message' => $message,'status'=>0);
        } 
        else{
            $message = $this->add_fest_database();
            $data = $message;
        }
    }
    else{
            $message = "Fest details are required";
            $data = array('message' => $message,'status'=>0);   
        }
    $this->output->set_content_type('application/json');
    $json = $this->output->set_output(json_encode($data));
    return $json;
 }
    function add_fest_database()
    {
        $youtubeWebsite = $this->input->post('txtyoutubewebsite');
        $gplusWebsite = $this->input->post('txtgpluswebsite');
        $this->load->model('model_fest');
        $data = array("fest_youtube"=>$youtubeWebsite,"fest_gplus"=>$gplusWebsite);
        return  data;
     }