Clint C.
Clint C.

Reputation: 688

jquery works in chrome and firefox, not IE

this won't work in IE... any ideas? When clicked it just loads the new page

<script type="application/javascript" src="lib/js/photos_fb_manage.js"></script>    
<ul class="photoList">
    <li id="k877575065600">
    <a href="/mem_fb_addphotos.php?addphoto.php?fbpid=877575065600&album=837932838940" id="877575065600" class="fbpm">
    <img src="http://photos-f.ak.fbcdn.net/hphotos-ak-snc4/155193_877575065600_22912405_47840445_3804175_s.jpg" />
    <span>Add To Profile</span>
    </a>
    </li>
    </ul>

    $(document).ready(function()
    {
        $('.fbpm').click(function(e)
        {
            fbpid = $(this).attr('id');
            $(this).find('span').text('PHOTO ADDED');
            $(this).parent('li').addClass('selected');
            $('#addedPhotos').show();
            $('<img src="images/loading.gif" id="loadimg" />').appendTo('#addedPhotos');

            $.ajax({
               type: "POST",
               url: "php/ajax/photos_fb_manage.php",
               data: "fbp="+ fbpid +"",
               success: function(msg){
                $('#loadimg').remove();
                $('<img src="'+ msg +'" />').appendTo('#addedPhotos');
               }
             });

            e.preventDefault();

        });
    });

Upvotes: 0

Views: 1859

Answers (3)

Raynos
Raynos

Reputation: 169531

Put the code inside a <script> tag.

<script type="text/javascript">

$(document).ready(function()
    {
        $('.fbpm').click(function(e)
        {
            fbpid = $(this).attr('id');
            $(this).find('span').text('PHOTO ADDED');
            $(this).parent('li').addClass('selected');
            $('#addedPhotos').show();
            $('<img src="images/loading.gif" id="loadimg" />').appendTo('#addedPhotos');

            $.ajax({
               type: "POST",
               url: "php/ajax/photos_fb_manage.php",
               data: "fbp="+ fbpid +"",
               success: function(msg){
                $('#loadimg').remove();
                $('<img src="'+ msg +'" />').appendTo('#addedPhotos');
               }
             });

            e.preventDefault();

        });
    });

</script>

I assume firefox/chrome quietly go "Oh you forgot the script tag. I'll fix that for you"

Upvotes: 1

Clint C.
Clint C.

Reputation: 688

Switched javascript type from application/javascript to text/javascript and it fixed it

Upvotes: 0

Praveen Prasad
Praveen Prasad

Reputation: 32127

move this e.preventDefault(); here

$('.fbpm').click(function(e)
    {
e.preventDefault();

remove this

event.returnValue = false;

Upvotes: 0

Related Questions