3

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.

5
  • Do you use different domain/subdomain on mobile view maybe? Commented Aug 6, 2015 at 8:34
  • no it is same for any device Commented Aug 6, 2015 at 8:35
  • Check if click event is triggered by inserting alert, console.log or adding breakpoint inside callback. If it is, then you now it's something else. Commented Aug 6, 2015 at 8:42
  • In mobile view now after clicking 6-7 times the request will be sent :( Commented Aug 6, 2015 at 8:44
  • on mobile it is working by double click Commented Aug 6, 2015 at 8:47

2 Answers 2

1

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 }); 
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

$(document).ready(function (){ 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}); }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.