jQuery: $.post error with IE

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mloforte
Forum Newbie
Posts: 2
Joined: Mon Mar 16, 2009 3:15 am

jQuery: $.post error with IE

Post by mloforte »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Hi,
I'm having problems with IE and jQuery.
I would get data by $.post and with Firefox it works, but doesn't with Internet Explorer.
I think is a problem of callback function because with Firefox prompts SUCCESS but with IE prompts ERROR.
Any ideas?

My code:

script.js

Code: Select all

 
function readFeed(id){
    var lid='';
    var fe='';
 
    $.ajax({
        url: 'readFeed.php',
        type: 'POST',
        dataType: 'text',
        timeout: 1000,
        error: function() {
        alert('Error.');
        },
        success: function(dt){
        alert('Sucsess: '+data);
        }
    });
    
    alert('End.');
    
    return;
}
 
readFeed.php

Code: Select all

 
<?php 
    echo "die";
    return; 
?>
 
index.php

Code: Select all

 
...
<tr class="source">
    <td id="source-$id">
        <div id="feed-$id" style="display:none;">-feed-</div>
    </td>
    <td>
        <a href="javascript&#058;void 200;" onClick="readFeed($id);" >Leggi</a>
    </td>
</tr>
...
 

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
hasti
Forum Newbie
Posts: 6
Joined: Sat Mar 14, 2009 5:37 am
Location: India
Contact:

Re: jQuery: $.post error with IE

Post by hasti »

Hi
Just change dataType: 'text' to json and check.
mloforte
Forum Newbie
Posts: 2
Joined: Mon Mar 16, 2009 3:15 am

Re: jQuery: $.post error with IE

Post by mloforte »

Code: Select all

dataType: 'json',
Nothing.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: jQuery: $.post error with IE

Post by kaszu »

@hasti: json won't work because server output is 'die', which isn't valid json.

Try:

Code: Select all

$.ajax({
    url: 'readFeed.php',
    type: 'GET',  //Changed 'POST' to 'GET' because you weren't sending any data
    dataType: 'text',
    timeout: 1000,
    error: function(xhr, textStatus) {
        alert('Error is:' + textStatus);    //Added textStatus to error message
    },
    success: function(dt){
        alert('Sucsess: '+dt);  //changed 'data' to 'dt'
    }
});
Please try and post what was textStatus alerted.
Post Reply