Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery post request not send in mobile view

Tags:

jquery

ajax

php

I m using following jquery code

var ajax_url = "tmp/ajax.php";
$(document).on('click', 'input[name="radio_view"]', function () {
    var view_array = {};
    view_array.session_id = $(this).attr('data-session_id');
    view_array.buyer_id = $(this).attr('data-buyer_id');
    view_array.lot_id = $(this).attr('data-lot_id');
    view_array.view = $(this).val();
    $.post(ajax_url, {act: 'save_view', view_array: view_array});
});

On full view in pc it is working fine the request will be sent to tmp/ajax.php but on mobile view the request not send in Network it is showing no request captured.

like image 464
Balbinder Singh Avatar asked Jun 04 '26 11:06

Balbinder Singh


1 Answers

Since you are using radio(As I am guessing by name attribute) button to trigger ajax call , mostly 'click' does not work in non-ie browser. Try changing from 'click' to 'change' event.

$(document).on('change', 'input[name="radio_view"]', function () {
//rest of the code
});
like image 122
Vivek Ranjan Avatar answered Jun 06 '26 00:06

Vivek Ranjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!