Jump to content

storing json.html value (generated within jQuery code), in a PHP $ variable


Recommended Posts

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


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?


Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

11 hours ago, chhorn said:

location.href = 'foo.php?data='+json.html


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... 

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.