No data returned to Firefox by Ajax call - IE OK

Hello

I'm very new to jQuery, so maybe I'm asking a stupid question. My apologies, if so.

I have an ajaxLink like so:

CHtml::ajaxLink('edit', array('fillEditConflictForm'), array('type'=>'POST', 'success'=>'fillConflictEditForm'));

In javascript I have a function:

function fillConflictEditForm(data, textStatus)

In the backend php the method fillEditConflictForm populates an array named $result and returns it with

echo $result;

Using IE, the javascript receives data. alert(data); displays the contents of the array and alert(textStatus) displays 'success'.

Using Firefox, alert(data); displays nothing, though alert(textStatus) displays 'success'.

Any ideas?

Please feel free to tell me to go away and learn jQuery properly. I know, I know…

Thanks in advance either way.

Hi,

I think that you have error in your ajaxLink. The second parameter is the URL for the AJAX request (read controller`s action). If you would like have alert you can do that:



CHtml::ajaxLink('edit', '#', array('type'=>'POST', 'success'=>'fillConflictEditForm'),array('id'=>'myLink'));




jQuery('#myLink').click(function(){alert('click')});


or create not ajax link and write own JS to send ajax request. Look what generate ajaxLink in your page and write something similar to that.

Hello, qwerty

Thank you. As ever, though, I'm not sure I understand. You say that "The second parameter is the URL for the AJAX request (read controller`s action)". In your code sample that is the '#', I assume:

your code:

CHtml::ajaxLink('edit', '#', array('type'=>'POST', 'success'=>'fillConflictEditForm'),array('id'=>'myLink'));

In my code:

CHtml::ajaxLink('edit', array('fillEditConflictForm'), array('type'=>'POST', 'success'=>'fillConflictEditForm'));

array('fillEditConflictForm') is the URL for the Ajax request. In my debugger I can see that the method is callled, can step through the code and see that $result is returned. However, my Javascript function seems to get no data in Firefox, Safari or Google chrome, but works as expected in IE.

I've just tried it as you suggested, i.e. with the URL for the Ajax request (the second parameter) as a simple string rather than as an array and that doesn't get to call the php method.

I may well follow your advice and write my own javascript.

Thank you.

Hi,

My fault, I thought of the link without ajax and I wrote with ajax. In my site I have something like:



CHtml::ajaxLink('delete', '#', array('id'=>'myLink'));


and:



jQuery('#myLink').click(function(){


	if (!confirm('Are you sure?')){


        	return false;


    	}			


    		


        id=jQuery('#manageUser .selected').attr('id');


        id=id.replace('uId','')


   		


	jQuery.ajax({


		type: 'POST',


  		url: '".Yii::app()->createUrl('user/manage/delete')."',


  		data: "id="+id,


  				


  		success: function(html){


                     jQuery('#MUajax').html(html);


		     jQuery('#uId'+id).remove();		    			     


	        },


		beforeSend: function(){


		    jQuery('#manageUser .loading').show();


		},


		complete: function(){


		  jQuery('#manageUser .loading').fadeOut('fast');


	        }


	});


});


to success you can add what you want.

Thanks for your help, qwerty. It's working fine now.