21299 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1359 Views |
-
onAfterWrite javascript Parse Error

19 February 2010 at 5:40pm
Hey All
Any one else have a similar problem?
I've included a Twitter class in Page, for auto tweeting after writing data.Goes like
public function onAfterWrite()
{
parent::onAfterWrite();
include('twitter.php');
$t = new Twitter('****','****');
$t->updateStatus("".$this->Title." http://www.mysite.com".$this->Link());
}Everything still works fine, data is saved and tweet is sent.
But I get two errors in base.js promoting me that errors occurred and it didn't go according to plan.From fire fox web tools plugin error console .
"reference to undefined property jQuery.cache[id][name]"
jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])And
"reference to undefined property window.opera"
if(window.opera&&['left','top','right','bottom'].include(style))Its probably a difficult thing to answer as it's an issue with my twitter class. Remove the twitter code and all works a charm. Just wondering if anyone had any pointers?
-
Re: onAfterWrite javascript Parse Error

19 February 2010 at 8:10pm
What twitter class did you use?
Maybe try this one instead: http://code.google.com/p/twitter-php/Btw. you could also use AbsoluteLink instead of yourdomain + Link. Eg.
$t->updateStatus($this->Title . ' ' . $this->AbsoluteLink());
-
Re: onAfterWrite javascript Parse Error

23 February 2010 at 1:51pm
Thanks for the reply banal. I was trying to find the AbsoluteLink, I remember seeing it a 6 months ago but couldn't remember.
I'm using Twitter class by Tijs Verkoyen, tried that google code one you linked to and I get the exact some thing. It sends the tweet fine, but javascript error on save, although the content appears to save.
It seems to be the include('twitter.class.php'); that's throwing it out.
-
Re: onAfterWrite javascript Parse Error

23 February 2010 at 1:56pm
Not best practice but I whacked the twitter class above the page class, and it works. Someone must have encountered this before, I'll try and find the correct way to include a custom class.
-
Re: onAfterWrite javascript Parse Error

23 February 2010 at 7:47pm Last edited: 23 February 2010 7:48pm
I wasn't sure how PHP handles includes, but after reading this: http://www.php.net/manual/en/function.include.php it appears that if you put an include statement inside a function, the code will be included as if it was defined in the function.
Maybe this causes the issue? Have you also tried include_once (just to be sure the class doesn't get included multiple times)? -
Re: onAfterWrite javascript Parse Error

11 March 2010 at 2:12pm
I can't remember off hand, but that is a good point. I usually include files before the class. I'll give it a whirl
| 1359 Views | ||
|
Page:
1
|
Go to Top |


