Page 1 of 1

Ajax

Posted: Thu Jun 11, 2015 2:41 pm
by KaL
ok i was wondering can i update image using ajax?

i tried and fail. but if i do strings only it works!:


Image with ajax:

Code: Select all

TableFooter();

function PartUpdate($a)
{
echo"<td><img height='128' width='128' src='{$webBaseDir}modules/tbs/images/$a.png'></td>";

 }

Ajax::RegisterFunction("PartUpdate","partToUpdate");

TableHeader("This part will be updated");
echo "<div id='partToUpdate'>";
echo"image will display here";
echo "</div>";
TableFooter();

ButtonArea();
Ajax::Button("Click Me","PartUpdate(3)");
EndButtonArea();

With Strings only:

Code: Select all

TableFooter();

function PartUpdate()
{
 echo "sucker!";
 
 }
Ajax::RegisterFunction("PartUpdate","partToUpdate");

TableHeader("This part will be updated");
echo "<div id='partToUpdate'>";
echo"hi";
echo "</div>";
TableFooter();

ButtonArea();
Ajax::Button("Click Me","PartUpdate()");
EndButtonArea();



can anyone figure out how to do ajax with image?

Re: Ajax

Posted: Thu Jun 11, 2015 11:10 pm
by KyleMassacre
Since it is using ajax/js/jquery or whatever your console log will let you know what your error is but I am going to go out on a whim here and say that it has to do with your string concatenation with your image directory. Also, I think your top "TableFooter()" is meant to be "TableHeader()"

Code: Select all

TableFooter();

function PartUpdate($a)
{
    echo "<td><img height='128' width='128' src='{$webBaseDir}modules/tbs/images/{$a}.png'></td>";//Notice the { and }
/* 
    or
    "<td><img height='128' width='128' src='".$webBaseDir."modules/tbs/images/".$a.".png'></td>";
*/
}

Ajax::RegisterFunction("PartUpdate","partToUpdate");

TableHeader("This part will be updated");
echo "<div id='partToUpdate'>";
echo"image will display here";
echo "</div>";
TableFooter();

ButtonArea();
Ajax::Button("Click Me","PartUpdate(3)");
EndButtonArea();