簡體   English   中英

Jquery - $。(post)數據響應與PHP不一致

[英]Jquery - $.(post) data response not consistent with PHP

Jquery代碼:

var code = $('#code'),
     id = $('input[name=id]').val(),
     url = '<?php echo base_url() ?>mali_oglasi/mgl_check_paid';
     code.on('focusout', function(){
        var code_value = $(this).val();
        if(code_value.length != 16 ) {
            if ($('p[role=code_msg]').length != 0 ) $('p[role=code_msg]').remove() ;
            code.after('<p role=code_msg>Pogrešan kod je unešen.</p>');
        } else {
            if ($('p[role=code_msg]').length != 0 ) $('p[role=code_msg]').remove() ;
            $.post(url, {id : id, code : code_value}, function(data){
                if(data != 'TRUE'){
                    code.after('<p role=code_msg>Uneti kod je neispravan.</p>');
                } else {
                    code.after('<p role=code_msg>Status malog oglasa je promenjen.</p>');
                    code.after(create_image());
                    code.remove();
                }
        });
        }
     });

PHP(Codeigniter)代碼:

function mgl_check_paid()
    {
        $code = $this->input->post('code');
        $id = $this->input->post('id');
        echo ($this->mgl->mgl_check_paid($code, $id)) ? 'TRUE' : 'FALSE';
    }

問題如下:當發送代碼並且它是正確的時,PHP部分將回顯TRUE ,並且JS將執行ELSE部分(發布后),但由於某種原因它沒有這樣做(它正在執行聲明的第一部分) )? 這段代碼有什么問題?

在php代碼中的echo語句后exit

echo ($this->mgl->mgl_check_paid($code, $id)) ? 'TRUE' : 'FALSE';
exit;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM