javascript - AJAX vs PHP Directly into JS -


i have little bit of conundrum. i'm developing wysiwyg editor plugin jquery web application. 1 of features inserting inline image tooltip based on images user has uploaded. example:

hello there name [i="profile_pic.png"]a. username[/i] 

the part i'm having issue is, when defining images available user, whether should insert php array directly javascript so:

var available_images = "<?=json_encode($user->profile->images)?>"; 

or go ajax returns encoded array of image sources? think inline php makes more sense since removes need unnecessary ajax call didn't think inserting inline php javascript terribly form?

any suggestions?

there's nothing wrong inserting data collected php js, how else js data? reason should consider ajax call be, if users upload new images while editing. mean information needs updated, make ajax call more appealing static json on page load.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -