Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iamxquisite's avatar

jQuery AJAX Request that returns html and php variable (Laravel)

I'm not sure if it is possible but I just started to really get into AJAX. I have the Ajax part working perfectly I am getting the "data" when there is a success: and displaying it inside a div using $("div").html(data);

Once the first success: goes through I have another form hidden and I use jquery to .show() it when the request is successful.

The second form has 2 hidden fields, that require 2 variables from the previous form that is successful. What would be the best way to get these 2 php variables into my second form that is hidden until the first one is successful.

0 likes
1 reply
Cronix's avatar

in the success event of the first ajax call, just grab the values you need from the form inputs on the first form and assign them to the inputs on your 2nd form.

$('#fieldFrom2ndForm').val($('fieldFromFirstForm').val());

Please or to participate in this conversation.