I know how much fun it is to get a question in return but here I go:

Why exactly do you want to use an ajax-call for an image replacement?
What you will be doing iscreating two server-calls from the browser.
1. replacing one image-tag with another
2. which causes the browser to start loading the new image.

If your javascript can figure out the name of the new image without a
server-call you can get away with a simple image-swapping without any-
ajax. If you really have to use ajax, remember that you only load the
filename or image-tag with ajax. Not the actual image.

Usually you can convert one name into the other 'name.jpg'->name-
thumb.jpg or 'thumbs/name.jpg'->'/fullsize/name.jpg'

If not you can cache a n array of some other js-datastructure in your
page ans access that when needed. Like in this extremely simple
example:
http://www.devx.com/tips/Tip/13653


On Jan 16, 10:54 am, J_Zar <[EMAIL PROTECTED]> wrote:
> I need to switch with a click an image.  Clicking on the thunmbnails
> should change the image in
> the div 'model_page_image'. This does not work and I get an error in
> the div from browser:
>
> "Not Acceptable
> Client browser does not accept the MIME type of the requested page."
>
> Where is the trick?
>
> My controller:
> -----------------------------------------
> function view($id = null, $image_id = null)
>     {
>         if ($id != null)
>         {
>                 $this->Model->id = $id;
>                 $this->set('model',$this->Model->read());
>                 $this->set('image_id',$image_id);
>         }
>         else
>         {
>                 echo "Errore! Id maldefinito...";
>         }
>
>         $this->render('view', 'ajax');
>     }
>
> Part of My view :
> ----------------------------------------------------
> // Get the first image
>         $img_list = explode(";", $model['Model']['image_list']);
>
>         //print_r($img_list);
>
>         $is_maschio = false;
>         if ($model['Model']['sesso'] == 'Maschio')
>                 $is_maschio = true;
>
>         if ($image_id == null || empty($image_id))
>         {
>                 if (!empty($img_list[1]))
>                 {
>                         $model_image = $html->link( 
> $html->image('../img_models/
> thumbnails/'.$img_list[1], array('border' => '0', 'style' => 'border:
> 1px solid #000000; margin: 5px 5px 5px 0px;', 'align' => 'right')), '/
> models/viewone/'.$model['Model']['id'], $htmlAttributes=null,
> $confirmMessage=false, $escapeTitle=false);
>                 }
>                 else
>                 {
>                         $model_image = $html->image('no_image.jpg', 
> array('border' => '0',
> 'style' => 'border:1px solid #000000;margin: 5px 5px 5px 0px;',
> 'align' => 'right'));
>                 }
>         }
>         else
>         {
>                 if (!empty($img_list[$image_id]))
>                 {
>                         $model_image = $html->link( 
> $html->image('../img_models/
> thumbnails/'.$img_list[$image_id], array('border' => '0', 'style' =>
> 'border:1px solid #000000; margin: 5px 5px 5px 0px;', 'align' =>
> 'right')), '/models/viewone/'.$model['Model']['id'],
> $htmlAttributes=null, $confirmMessage=false, $escapeTitle=false);
>                 }
>                 else
>                 {
>                         $model_image = $html->image('no_image.jpg', 
> array('border' => '0',
> 'style' => 'border:1px solid #000000;margin: 5px 5px 5px 0px;',
> 'align' => 'left'));
>                 }
>         }
> /*
>         $model_image = $html->image( $model_image_url, array('border' => '0',
> 'style' => 'border:1px solid #000000; margin: 5px 5px 5px 0px;',
> 'align' => 'right'));*/
>
>         echo "<table id='model_page_table' width=\"100%\" cellpadding=\"0\"
> cellspacing=\"0\"><tbody><tr>";
>         echo "<td id='model_page_desc'>\n";
>         echo "<br><font id='model_page_title'>".$model['Model']['nome']."</
> font><br>";
>
>         if ($is_admin)
>                 echo "<div style='float:right; border: 1px solid #000000; 
> margin:
> 5px; padding: 5px;'>".$this->renderElement('adminloc', array('model'
> => $model))."</div>";
>
>         echo "<table width='100px;' cellpadding=\"0\" cellspacing=
> \"0\"><tbody>";
>         echo "<tr><td style='text-transform: uppercase;'>Altezza:</td><td>".
> $model['Model']['altezza']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Taglia :</td><td>".
> $model['Model']['taglia']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Spalle :</td><td>".
> $model['Model']['spalle']."</td></tr>";
>         if ($is_maschio)
>                 echo "<tr><td style='text-transform: uppercase;'>Torace 
> :</td><td>".
> $model['Model']['petto']."</td></tr>";
>         else
>                 echo "<tr><td style='text-transform: uppercase;'>Seno 
> :</td><td>".
> $model['Model']['petto']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Girovita :</td><td>".
> $model['Model']['girovita']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Fianchi :</td><td>".
> $model['Model']['fianchi']."</td></tr>";
>         if ($is_maschio)
>         {
>                 echo "<tr><td style='text-transform: uppercase;'>Girocollo :</
> td><td>".$model['Model']['girocollo']."</td></tr>";
>                 echo "<tr><td style='text-transform: uppercase;'>Gamba 
> :</td><td>".
> $model['Model']['gamba']."</td></tr>";
>         }
>         echo "<tr><td style='text-transform: uppercase;'>Scarpe :</td><td>".
> $model['Model']['scarpe']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Occhi :</td><td>".
> $model['Model']['occhi']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Capelli :</td><td>".
> $model['Model']['capelli']."</td></tr>";
>         echo "<tr><td style='text-transform: uppercase;'>Note :</td><td>".
> $model['Model']['note']."</td></tr>";
>
>         echo "</tr></tbody></table>";
>
>         echo "</td>";
>         echo "<td>\n";
>         echo $ajax->div('model_page_image');
>         echo $model_image;
>         echo $ajax->divEnd('model_page_image');
>         echo "</td>";
>         echo "</tr></tbody></table>";
>
>         echo "<div 'model_page_image_box'>";
>         for ($i = 1; $i < sizeof($img_list); $i++)
>         {
>                 echo $ajax->link($html->image('../img_models/thumbnails/'.
> $img_list[$i], array('border' => '0', 'style' => 'border:1px solid
> #000000; margin: 0px;', 'align' => 'left')),
>                  '/models/view/'.$model['Model']['id'].'/'.$i,
>                  array('update' => 'model_page_image',
>                        'loading' => 'Effect.Appear(\'model_page_image
> \')'),
>                  null,
>                  FALSE
>                 );
>         }
>         echo "</div>";
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to