Welcome Guest, Not a member yet? Register   Sign In
jquery json update (Solved in round about way)
#1

[eluser]gazza7364[/eluser]
Hi

I'm trying to send a link with data via jquery and json. Everything works except the lnik I want to use to edit information about photos. No part of the link shows not even the word edit.

Here is part of the code being sent.
Code:
$output = "<div &lt;?php echo anchor('photos/edit($data->photo_id'), 'Edit'); ?&gt;</div>";
  $output.="
  <table cellpadding='0' cellspacing='0''>
  

  <tr>
   <td>Image Name : </td>
   <td>$data->imagename</td>
  </tr>
  
  <tr>
   <td> PhotoAlbum : </td>
   <td>$data->photo_album</td></tr>

  <tr>
   <td> Subject : </td>
   <td>$data->subject</td></tr>

  

  </table><table>
  
  <tr>
  
   <td align='center'>$image</td>
  </tr>
  
  </table>";
  
  echo json_encode(array('html' => $output));

The part I'm having trouble with is the first line, I'm not sure if you can send php this way using jquery and json, if not is their a way as I need to have the link with the photo id.?

Thanks in advance.
#2

[eluser]PhilTem[/eluser]
Nope, this won't work. It will parse the source code (except for replaced variables $data and stuff).

Have you worked with PHP before? If so, you should know that you have to concatenate the strings for output like so

Code:
$output = "<div>" . echo anchor('photos/edit($data->photo_id'), 'Edit') . "</div>";
#3

[eluser]gazza7364[/eluser]
[quote author="PhilTem" date="1332856181"]Nope, this won't work. It will parse the source code (except for replaced variables $data and stuff).

Have you worked with PHP before? If so, you should know that you have to concatenate the strings for output like so

Code:
$output = "<div>" . echo anchor('photos/edit($data->photo_id'), 'Edit') . "</div>";
[/quote]

Yes I have use php before, I've been messing around with this for a while, when I use your suggestion, which I have already tried I get a blank page. For some reason the coding shows up incorrect in the editor as their a mistake, but not sure where. I have copied your version as is, but still I get a blank page. When I remove this line the page loads :-(
#4

[eluser]gazza7364[/eluser]
Hi

My solution in the end was to use onclick and jquery to pass the id, to he edit form and get the correct information from the id and load into a div.




Theme © iAndrew 2016 - Forum software by © MyBB