I was getting a similar problem when asking for a JSON response 
(dataType: "json").  My issue was either that I had a subtle bug in the 
success function, or my resulting JSON wasn't quite right.  I've been 
able to avoid the problem by making sure my JSON property names are in 
quotes (i.e. { "name" : "bob" }  ).  I also had to make sure that the 
data I was pulling from my database wasn't inserting hidden characters 
in my strings (unicode, carriage returns, etc.).  Luckily I'm using PHP 
and Cold Fusion so can use addslashes() and jsstringformat() respectively.

In your particular case, it looks like you are getting HTML back.  Are 
you sure your HTML is valid?  Did you remove everything from your 
success function and just put in an alert("hello"); type statement? (see 
if you are even getting there).  If that alert doesn't go, then you KNOW 
the problem is in your results.  If you see the alert, then you can then 
try to alert(msg), and see what you get.  (basically, start the process 
of figuring out if it's your function, or your resulting data).  Chances 
are it's in the data though.  I don't see any glaring errors in your code.

HTH some....

Shawn

Chris - Implied By Design wrote:
> I have an Ajax function I'm using to test right now. When the function
> is called (upon a click), it runs the function, but displays the
> "Error, please try again" message. In Firebug, it looks like the
> function is returning the correct msg. I was using 1.0.2 (I think)
> where it worked, minus the replaceWith function, and then I upgraded
> to 1.1.2 and now it's showing the error message.
> 
> Here's the function below, any ideas on what I'm doing wrong?
> 
> function testAjax(id,page,sort) {
>                       $.ajax({
>                                       url: 'ajaxtable/refresh',
>                                       type: 'GET',
>                                       data: 'id=' + id + '&page=' + page + 
> '&sort=' + sort,
>                                       error: function(){
>                                                       alert('Error, please 
> try again');
>                                       },
>                                       success: function(msg){
>                                               
> $('div').replaceWith('<div>Test</div>' );
>                                                       alert(msg);
> 
>                                       }
>                       });
>               }
> 
> 
> Thanks!

Reply via email to