Wednesday, August 5, 2009

Re: Pass data to jquery

I'm not sure that I understand what that response is. Is that your
view file? How are you passing that back to javascript?

On Wed, Aug 5, 2009 at 10:23 AM, Dave Maharaj ::
WidePixels.com<dave@widepixels.com> wrote:
>
> Here is the controller function
>
> function add($showcase_id = null)
>      {
>              if (!empty($this->data)) {
>              $this->data['Entry']['id'] = $this->Entry->generate11Key();
>              $this->data['Entry']['showcase_id'] = $showcase_id;
>              if ($this->Entry->save($this->data)) {
>                  $image_path =
> $this->Image->upload_image_and_thumbnail($this->data, 'image', '640', '360',
> '177', '100', 'entries', $this->Auth->user('slug'),
> $this->data['Entry']['id']);
>                  if (isset($image_path)) {
>                      $this->Entry->saveField('image', $image_path);
>                      $this->set('newImage', $image_path);
>                  }
>                  $this->Session->setFlash(__('New entry saved!.', true));
>                  //$this->redirect(array('controller' => 'showcases',
> 'action' => 'view', $showcase_id));
>              } else {
>                  $this->Session->setFlash(__('Error message. Please, try
> again.', true));
>              }
>          }
>          $this->set('showcase', $showcase_id);
>            $this->set('entry', $this->data['Entry']['id']);
>
>      }
>
> The response after upload shows this snip where newImage = what I need to
> send to the script
>
> $___viewFn      =       "/app/views/entries/add.ctp"
> $___dataForView =       array(
>        "slug" =&gt; "austinmaharaj",
>        "newImage" =&gt; "joesmith_25f31f1f34c.jpg",
>        "showcase" =&gt; "6e87ea500fe",
>        "entry" =&gt; "25f31f1f34c"
> )
>
> -----Original Message-----
> From: brian [mailto:bally.zijn@gmail.com]
> Sent: August-05-09 11:44 AM
> To: cake-php@googlegroups.com
> Subject: Re: Pass data to jquery
>
>
> You haven't shown how/what your controller is sending back to the client.
> Why does the response contain the SQL query? In any case, just send the new
> filename back. Use JSON, for example. Have a look at the
> json_encode() function.
>
> On Wed, Aug 5, 2009 at 9:27 AM, Dave Maharaj ::
> WidePixels.com<dave@widepixels.com> wrote:
>> I am uloading a file to the server using an ajax upload script. Now
>> everything is working fine except I cant figure out how to get the
>> name of the file uploaded back to the page after uploading.
>>
>> Using Valums ajax upload script
>>
>> The file that gets uploaded say 03.jpg gets renamed to
>> $user_$unique_id so it turns into myname_12565895.jpg on the server
>>
>> I used
>> alert(response);  in the script after succesful upload and see
>>
>> UPDATE `entries` SET `image` = 'joekool_b9b071c1e64.jpg'  WHERE
>> `entries`.`id` = 'b9b071c1e64'
>>
>> How can I grab the image` = 'joekool_b9b071c1e64.jpg'  and pass it
>> back to the script rather than the 03.jpg. After upload it says 03.jpg
>> uploaded succesfully but i need the server converted name so I can
>> display the image instead of the name.
>>
>> Ideas?
>>
>> Dave
>> >
>>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: