Marco_ Posted March 6, 2020 Share Posted March 6, 2020 I have a submit.php file that includes the following jQuery code: <script> [...] request.done(function( json ) { jQuery('input[name=thumbnail-url]').val(json.thumbnail_url); jQuery('input[name=job_title]').val(json.title); jQuery('textarea[name=htmlcode]').val(json.html); [...] </script> I need to remove jQuery('textarea[name=htmlcode]').val(json.html); and pass the "json.html" value into a PHP variable in another php file (functions.php). The code in the functions.php file is already there. The thing i need to do (and i am seriously struggling with it) is placing the value of json.html into a $phpvariable that i can then call from the function.php file. Do you need any more info for this issue? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/310216-storing-jsonhtml-value-generated-within-jquery-code-in-a-php-variable/ Share on other sites More sharing options...
chhorn Posted March 6, 2020 Share Posted March 6, 2020 location.href = 'foo.php?data='+json.html var_dump($_GET['data']); maybe you need to escape that somehow. Or use AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/310216-storing-jsonhtml-value-generated-within-jquery-code-in-a-php-variable/#findComment-1575191 Share on other sites More sharing options...
requinix Posted March 6, 2020 Share Posted March 6, 2020 Is this not already going through PHP? That request.done suggests you're doing AJAX... Quote Link to comment https://forums.phpfreaks.com/topic/310216-storing-jsonhtml-value-generated-within-jquery-code-in-a-php-variable/#findComment-1575199 Share on other sites More sharing options...
Marco_ Posted March 6, 2020 Author Share Posted March 6, 2020 4 hours ago, requinix said: Is this not already going through PHP? That request.done suggests you're doing AJAX... the input/job_title and input/thumbnail-url they both already go through php because these are real visible fields on the form that gets physically populated on the fly. The other field instead textarea/htmlcode is hidden hence cannot be populated on the fly and the value currently is not passed through php. i have a receiving $phpvar now in the file functions.php that will need to get the value from this submit.php form that currently is not getting cause it is not passed. i checked the http header request and i am struggling in finding a way to pass this value. Quote Link to comment https://forums.phpfreaks.com/topic/310216-storing-jsonhtml-value-generated-within-jquery-code-in-a-php-variable/#findComment-1575210 Share on other sites More sharing options...
Marco_ Posted March 6, 2020 Author Share Posted March 6, 2020 11 hours ago, chhorn said: location.href = 'foo.php?data='+json.html var_dump($_GET['data']); maybe you need to escape that somehow. Or use AJAX. hi Chhorn, thanks for this. sorry but i am pretty new to coding. the two lines that you wrote must be written exactly like this or i need to replace something in there? e. g. foo.php and var_dump?! additionally both of these lines must be included in the submit.php file or some of them in another file? last thing, what would i need to escape, and what does that mean? Thanks a lot, hope in the near future will be able to avoid these silly questions... Quote Link to comment https://forums.phpfreaks.com/topic/310216-storing-jsonhtml-value-generated-within-jquery-code-in-a-php-variable/#findComment-1575211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.