Problems using $.ajax when creating a wigdet

Problems using $.ajax when creating a wigdet

Hi

I'm trying to create a widget, and at somepoint I need to make an ajax request using $.ajax. The problem is that I can't access the options variables in the ajax .done event. What I'm doing wrong? Here is a simplified version of the code. I'm getting  Cannot set property 'data' of undefined in line 25. If I try to work the variables outside the ajax function everything works fine. Thank you

  1. $(function(){

  2. $.widget("custom.imagesManager",{

  3. options:{
  4. url:'test.php',
  5. post_data:0,
  6. data:null;
  7. },

  8. _create: function(){
  9. this._refresh();
  10. },

  11. _refresh: function(){

  12. $.ajax({
  13. type:'POST',
  14. url:this.options.url,
  15. data:this.options.post_data,
  16. dataType: 'json',
  17.                                 cache:false
  18. })
  19. .done(function(data){
  20. this.options.data = data;
  21. });
  22.                }
  23. });
  24. });