0

I tried to encapsulate $.post() to an object and handle the callback using the object's method/function. The net suggest that I should use JQuery $.proxy() to achieve it like question. However it seems that jquery (or me) is failing to get the right context.

Here is a live demo http://jsfiddle.net/komaruloh/WSBBC/

Community
  • 1
  • 1
Komaruloh
  • 6,841
  • 3
  • 15
  • 7

1 Answers1

1

You're doing it right. The context is preserved inside this.display. Try to log "this".

http://jsfiddle.net/WSBBC/1/

Maybe something is wrong with the PHP file...

bitlyfied
  • 28
  • 3
  • The mistake is mine. And you are absolutely right, it was the json value returned by the php that is not correctly formatted. Thanks for your quick answer and pointing me the right direction. :) – Komaruloh Jun 27 '11 at 08:14
  • 1
    For those who curious with working demo. Here is one. http://jsfiddle.net/komaruloh/6H7pw/ . Using geonames.org json web service. – Komaruloh Jun 27 '11 at 08:18