New Ajax Problem - File Upload

3 messages Options
Embed this post
Permalink
StubbTX

New Ajax Problem - File Upload

Reply Threaded More More options
Print post
Permalink
This seems to be my new favorite place...

OK, I'm trying out the jQuery file upload on page 132 and having a problem with Listing 8-16.  I'm copying the code directly from the source files and compared it to the text in book.  It looks correct.  I've also properly installed the jQuery code.

Anyway, the view renders but when I browse to a text file and click "Upload File" I receive a javascript error.

Error: illegal character
Source File: http://dev.blogs.com/posts/add
Line: 1, Column: 60
Source Code:
$('#postAddForm').ajaxSubmit({target: '#postTextUpload',url:\"/posts/text'});return false;

I've tried both IE and FF and same results.  I've also tried various searches for documentation on the correct parameters for the ajaxSubmit but no luck.

Anyone have any ideas?
StubbTX

Re: New Ajax Problem - File Upload

Reply Threaded More More options
Print post
Permalink
Hey, it's me again and yet again I'm answering my own post.  If I can always get the answer my questions this way, I don't mind.  

I called my wife over (who is a developer) for a second set of eyes.  Turns out the code in listing 8-16 has extraneous double-quote ( " ).  I swear I checked this, but talking it out with her it worked by replacing it with a single quote.

Wrong Code
<?=$form->button('UploadText',array('onClick'=>'$(\'#postAddForm\').ajaxSubmit({target: \'#postTextUpload\',url:\"'.$html->url('/posts/text').'\'});return false;'));?>


Corrected Code
<?=$form->button('UploadText',array('onClick'=>'$(\'#postAddForm\').ajaxSubmit({target: \'#postTextUpload\',url:\''.$html->url('/posts/text').'\'});return false;'));?>

The corrected code works for me and the bold part is a pair of single quotes NOT a double quote.

davidgolding

Re: New Ajax Problem - File Upload

Reply Threaded More More options
Print post
Permalink
Thanks for the catch, StubbTX. I'll get this submitted to the errata. Nothing like one character to screw things up :)
--Dave

Author, "Beginning CakePHP: From Novice to Professional"

[ get your copy at: http://www.amazon.com/Beginning-CakePHP-Novice-Professional/dp/1430209771/ ]