How do i get the value back to the ajax success?
I tried <cms:gpc> and json, etc.
But no value returned.
I tried <cms:gpc> and json, etc.
But no value returned.
<cms:db_persist
..
>
<cms:if k_error >
<cms:abort>ERROR</cms:abort>
<cms:else_if k_success />
<cms:abort><cms:show k_last_insert_id /></cms:abort>
</cms:if>
</cms:db_persist >
$.ajax({
..
..
success: function(response){
if(response != 'ERROR'){
window.location.href = "generate-sos.php?q="+response;
}
}
});
please see @cheesypoof's implemntation where he sends back complex data as a JS object - viewtopic.php?f=2&t=10415
$(document).on('click','#generatesos',function(e) {
$.ajax({
url:"<cms:show k_site_link />fir-sos-json.php",
type:"POST",
data:{
<cms:pages id=rt_id limit='1' >
...
"ipt_disaster_image":<cms:escape_json><cms:show_securefile 'ipt_disaster_image' ><cms:securefile_link file_id /></cms:show_securefile></cms:escape_json>,
...
</cms:pages>
},
contentType:"application/json; charset=utf-8",
success: function(data){
alert("Data Save");
}
});
});
<cms:set disaster_image="<cms:gpc 'ipt_disaster_image' method='get' />" scope="global" />
<cms:db_persist
...
ipt_disaster_image = "<cms:show disaster_image />"
...
>
I suggest to data-stream (base64) the image (https://en.wikipedia.org/wiki/Data_URI_scheme) and save it into a textarea via db_persist.
<br><b>Name:</b> Required field cannot be left empty
<cms:set b64_img="<cms:show_securefile 'ipt_disaster_image' ><cms:securefile_link file_id /></cms:show_securefile>" />
<cms:php>
global $b64_img;
global $b64_data;
$b64_img = file_get_contents('<cms:show b64_img />');
$b64_data = base64_encode($b64_img);
</cms:php>
Is it possible to make the base64 image encoded string small
Of course, there is another (more complicated) way - pass on solely the accessible URL of the image, then on the recipient side download it with PHP (curl) and you are free to do with it whatever needed.