javascript - Correct userid not getting sent during post event -
hi hope can have gifts plugin not including userid in request , therefore fails work, bellow js code. when check request body viewed in console shows
to_user=&gift_id=18&msg= can see no userid being sent to_user
in console view if add to_user=532&gift_id=18&msg= , posts gift sent expected.
this code on modal popup
<script type="text/javascript"> if( false ){ $('#gift-modal').show(); } $('.giftimage').on('click',function(){ $('.giftimage').removeclass('activegift'); $(this).addclass('activegift'); }) $('#send_gift').on('click',function(){ var gift = $(this).parent().parent().find('.giftimage.activegift'); var gift_price =gift.data('price'); var gift_id =gift.data('giftid'); var msg=''; data={to_user: $('#userid_gift').val() , gift_id:gift_id , msg:msg}; $.ajax({ type: "post", url: "https://www.asiansocialdate.com/send_gift", data: data, success: function(data){ toastr.success(data.message); window.location.reload(); }, error: function(xmlhttprequest, textstatus, errorthrown) { toastr.error("some error"); } }); }) </script>
this code send_gift.blade.php
@parent <script> $('#giftmodal').on('click',function(){ $('#userid_gift').val('<?php echo e($user_id); ?>'); $('.gift_header').text("{{{trans('app.send_gift')}}}"); }) </script>
this modal code
<div id="mymodal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- modal content--> <div class="modal-content"> <div class="modal-header" style="background:#007be6"> <button type="button" class="close" data-dismiss="modal">× </button> <h4 class="modal-title gift_header">{{{trans('giftplugin.giftheader')}}}</h4> </div> <div class="modal-body"> @foreach($gifts $gift) <div style="display: inline-block;height: 70px;width: 70px; margin: 25px;"> <img class="giftimage" data-price="{{{$gift->price}}}" data-giftid=" {{{$gift->id}}}" src={{{url('uploads/gifts/'.$gift->icon_name)}}} /> <span class="grey">{{{$gift->price}}} {{{trans('app.credits')}}} </span> </div> @endforeach <div id="gifts-message" class="gifts-msg gifts-msg--visible"> <input type="text" name="msg" id="gift_text" class="input input--sm" placeholder="{{trans('giftplugin.type_message_placeholder')}}"> </div> </div> <div class="modal-footer"> <!-- <button type="button" class="btn btn-default" data-dismiss="modal">close</button> --> <input type="hidden" id="userid_gift" value='' /> <button type="button" class="btn btn-default " id="send_gift" style="margin: 0" data-dismiss="modal">{{{trans('app.continue')}}}</button> </div> </div> </div> </div>
any suggestions on how can work?
edit have made progress if edit line
<input type="hidden" id="userid_gift" value='#userid_gift' />
it still fails value has % sign first digit in console view can see
to_user=%23userid_gift&gift_id=19&msg=
the number should 523 idea why changing 5 % sign
another edit
i have changed value
<input type="hidden" id="userid_gift" value='#' />
however still adding % user id
to_user=%23&gift_id=11
anyone have suggestions on how can resolve this
thanks
Comments
Post a Comment