I read different articles on PHP and JS differences.
Code I have:
<html>
<div id"response"> GETTING ALL CONTENT HERE</div>
</html>
<script>
jQuery(function($) { // DOM is now ready
<!-- CHANGING COLOR OF FIELD -->
$('.metal').hover(function(){
$main_text = $(this).text();
$(this).text("Pievienot grozam");
},function(){
$(this).text($main_text);
});
<!-- AJAX CALL -->
$.ajax({
url: "/modules/mod_shop/response.php",
type: "POST",
async: true,
cache: false,
data: ({dataList: dataList}),
dataType: "json",
success: function (dataList) {
console.log(testName);
jQuery.each(dataList, function(i, data) {
var testValue = 'smth..';
var htmlContainer = '<p>data.name</p><h1><?php echo testFunction ($testValue );?></h1>';
$('#response').append(htmlContainer);
});
}
});
});
});
</script>
One is server side, other on client-side. I'm asking on how to make this work? An alternative options here.
Right now, with ajax I get json objects. I can get them quite easily, but I cant get out pictures, because I use special function testFunction() which resizes pictures. Is there some way to use this php function and pass in specific parameter? Something like this:
<html>
// in html part
foreach (run through all data){
<img src="<?php echo testFunction($url) ?>"></img>
}
</html>
Is there a way to just load all pictures using php (somewhere) and then, when I do ajax call, automatically pass these pictures? (As PHP runs first and only then JS)? How would I do this? Any ideas/suggestions are welcome!