Home > OS >  Sending Variable Data as Post Using Ajax
Sending Variable Data as Post Using Ajax

Time:11-03

I have been looking into a problem, but I can't figure out how to solve it or what the solution is. I am working on my website using image

So now I am even more puzzled as to why it doesn't work when I try to insert it into the table.

CodePudding user response:

I know this isn't the right answer for the question, but it is an alternative and maybe you will find it somewhat helpful. The solution I came up with was to take the value given by your jquery and set it to an invisible input value inside the sumbit form.

<form id="reviewForm" method="POST" action="">
                <textarea type="text" id="reviewTextarea"name="uploadReview</textarea>
                <div id="submitReview">
                <input type="hidden" id="jqValue" name="jqueryValue" value=""/>
                    <button id="submitButton" type="submit" form="reviewForm">Submit</button>
                </div>

Then take the variable ratedIndex and give it to your inputjqValuevalue like this

$('.fa-star').on('click', function (){
            ratedIndex = parseInt($(this).data('index'));
            $("#jqValue").val(ratedIndex);
        });

Lastly call in your php $ratedIndex=$_POST["jqueryValue"];

Like I said this just an alternate way to solve your problem if you are stuck and cant make ajax work you can use this. I posted because you might have not thought about doing it this way.

  • Related