开发者

Codeigniter echo/var_dump not working

Why doesn't var_dump work here, the ajax call is successful, but there is nothing printed, not even a string literal print from the PHP.

My controller

function check_links() {            
  $matches = $this->input->get('matchesJSON');        
  var_dump($matches);
  //$this->load->view('publish_links_view');
}

Ajax call

$.ajax({
  type: 'GET',
 开发者_如何转开发 dataType: 'json',
  cache: false,
  data: 'matchesJSON='+matchesJSON,
  url: 'publishlinks/check_links',
  success:                    
    function(response) {

    }
})    


I assume you're expecting it to var_dump to the browser.

Ajax happens "behind the scenes", so it wouldn't output to your browser, you'd have it in your success handler's response argument.

if you want to test it just hit the url directly with your browser.

http://ciroot/index.php/publishlinks/check_links?matchesJSON=test%20text

Also, you can monitor all of your AJAX requests / responses with the Browser extension Firebug, very useful in situations like this.


it seems to be a problem with your ajax call, not with codeigniter

start with removing dataType: 'json' - jQuery will find type of content itself as it's not json

and you need to output response in your function:

function(response) { window.alert(response) }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜