WordPress ajax current user not updating

Upon successful ajax submission, i am still getting back the old values. E.g.

$('#preview-cover').attr('src','<?php $new_user = wp_get_current_user(); 
wp_get_attachment_thumb_url( $new_user->cover); ?>");

This is used to call the newly uploaded image, but it is still calling the previous image. If i refresh the page, then the new image is visible.

Read More

Please advice where have i gone wrong..

Here is the result using the given code @eagle
Here is the result

Related posts

Leave a Reply

1 comment

  1. It is likely caching your old file. Try:

    $('#preview-cover').attr('src','<?php $new_user = wp_get_current_user(); 
    wp_get_attachment_thumb_url( $new_user->cover); ?>?rnd=' + Math.random());