Strange alert in CGridView

Hi!

When I click on head columns in the table for sorting or on pagination links I have the popup alert with the html page I requesting which. I have no errors on backend, the content received from the server is right, but the page content is not updating and renderes in alert instead.

I try to render content with CListView but the result is the same.


<table class="tListView">

    <tr>

        <th>Name</th>

        <th>Title</th>

        <th>URL</th>

    </tr>

    <?php $this->widget('zii.widgets.CListView', array(

        'dataProvider' => $dataProvider,

        'itemView' => '_view',

        'sortableAttributes' => array(

            'name',

            'title',

            'url',

        ),

        'pager' => array(

            'header' => '',

        ),

    )); ?>

</table>

Index action:


public function actionIndex()

{

	$dataProvider = new CActiveDataProvider('Cat');

	

	$this->render('index', array(

		'dataProvider' => $dataProvider,

	));

}

What is the content of the error msg?

@frantic

You may think it’s the requested page shown in the alert, but it’s in fact an error page shown there with all the HTML codes… you need to look where the <BODY> begins… and there find the error that is reported…

If you use firefox and it’s extension firebug than it’s much simpler as there you can see the actual page returned

That’s where the problem is. I copied the html from alert and tried to find an error, but no errors in there. I also open requested page in new tab and there is the right content - no errors and the data sorted by column I clicked.

Try to post here the content of the alert…


<!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" xml:lang="en" lang="en">

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


    <base href="http://localhost/newsite/" />

    

            

    <script type="text/javascript">

    /*<![CDATA[*/

        asynUrl = {

            addNewCat : '/newsite/admin/cat/add'

        };

    /*]]>*/

    </script>


    <link rel="stylesheet" type="text/css" href="/newsite/assets/bfbae0d9/listview/styles.css" />

<link rel="stylesheet" type="text/css" href="/newsite/assets/41fdbab4/pager.css" />

<link rel="stylesheet" type="text/css" href="/newsite/css/blueprint/screen.css" media="screen, projection" />

<link rel="stylesheet" type="text/css" href="/newsite/css/blueprint/print.css" media="print" />

<link rel="stylesheet" type="text/css" href="/newsite/assets/ca9ef772/plugins/PineNotify/jquery.pnotify.default.css" />

<link rel="stylesheet" type="text/css" href="/newsite/assets/ca9ef772/plugins/PineNotify/smoothness/jquery-ui-1.8.7.custom.css" />

<link rel="stylesheet" type="text/css" href="/newsite/assets/ca9ef772/css/main.css" media="all" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

<script type="text/javascript" src="/newsite/assets/65adab7c/jquery.ba-bbq.js"></script>

<script type="text/javascript" src="/newsite/assets/ca9ef772/plugins/PineNotify/jquery.pnotify.min.js"></script>

<script type="text/javascript" src="/newsite/assets/ca9ef772/js/index.js"></script>

<title>newsite - Cat</title>


</head>

<body>

<div class="container">


	<div id="header">

		<h2>Newsite</h2>

	</div>


	<div class="admTopMenu">

		<ul id="yw2">

<li><a href="/newsite/admin/index">Home</a></li>

<li><a href="/newsite/admin/user">Users</a></li>

<li><a href="/newsite/admin/cat">Cats</a></li>

<li><a href="/newsite/admin/material">Materials</a></li>

<li><a href="/newsite/admin/tag">Tags</a></li>

<li><a href="/newsite/admin/photo">Photos</a></li>

<li><a href="/newsite/admin/movie">Movies</a></li>

<li><a href="/newsite/admin/fact">Facts</a></li>

<li><a href="/newsite/admin/opinion">Opinions</a></li>

<li><a href="/newsite/admin/comment">Comments</a></li>

<li><a href="/newsite/admin/setting">Settings</a></li>

<li><a href="/newsite/admin/logout">Logout</a></li>

</ul>	</div>

    

    <div class="admBread">

	    <div class="breadcrumbs">

<a href="/newsite/admin/index">Home</a> &raquo; <span>Cats</span></div>    </div>

    

	<div class="admContent">

        <div class="portlet" id="yw3">

<div class="admPortlet">

<ul class="operations" id="yw4">

<li><a href="/newsite/admin/cat/create">Create Cat</a></li>

</ul></div>

</div>		

<table class="tListView">

    <tr>

        <th>Name</th>

        <th>Title</th>

        <th>URL</th>

    </tr>

    <div id="yw0" class="list-view">

<div class="keys" style="display:none" title="/newsite/admin/cat/index/Cat_sort/name?ajax=yw0"><span>6</span><span>7</span><span>8</span><span>1</span><span>12</span><span>11</span><span>10</span><span>9</span><span>2</span><span>13</span></div>

<div class="summary">Displaying 1-10 of 11 result(s).</div>

<div class="sorter">

Sort by: <ul>

<li><a class="asc" href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name.desc">Name</a></li>

<li><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/title">Title</a></li>

<li><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/url">Url</a></li>

</ul></div>

<div class="items">

<tr class="odd">


    <td>df</td>


    <td>eefef</td>


    <td>fefef</td>


</tr>


// ....Other tr-s here....


</div>

<div class="pager"><ul id="yw1" class="yiiPager"><li class="first hidden"><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name">&lt;&lt; First</a></li>

<li class="previous hidden"><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name">&lt; Previous</a></li>

<li class="page selected"><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name">1</a></li>

<li class="page"><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name/Cat_page/2">2</a></li>

<li class="next"><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name/Cat_page/2">Next &gt;</a></li>

<li class="last"><a href="/newsite/admin/cat/index/ajax/yw0/Cat_sort/name/Cat_page/2">Last &gt;&gt;</a></li></ul></div></div></table>

	</div>


	<div id="footer">

		Copyright &copy; 2010 newsite.Ru

	</div>


</div>

<script type="text/javascript" src="/newsite/assets/bfbae0d9/listview/jquery.yiilistview.js"></script>

<script type="text/javascript">

/*<![CDATA[*/

jQuery(function($) {

jQuery('#yw0').yiiListView({'ajaxUpdate':['yw0'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'list-view-loading','sorterClass':'sorter'});

});

/*]]>*/

</script>

</body>

</html>

Hmmm. there is no error…

Have you checked that somewhere in the java code you are not interfering with the <a href…> links?

I found out the reason. It’s because of global ajax settings I declare:


$.ajaxSetup({

    type: "post",

    dataType: "json"

});

I edited the jquery.yiilistview.js file to display the error type. It showed "Invalid JSON". Seems the code there in the error method rely on errors on the server side, bacause it alerts only responseText:


alert(XMLHttpRequest.responseText);

Anyway, adding the parameter dataType: “html” resolves the problem. Thanks for pointing me the right way :)