0

I have appearing issue on ajax response in my WordPress site and ajax response is

function routineSkin(term,termId){
    alert("Termssss => "+ term  + " TermId=> "+ termId);
    var skinRoute = jQuery("#paraskintype").val("skintype_"+term);
    jQuery("#paraTarget").val("");
    jQuery('#looking_nm').css('display','block');   
    jQuery.ajax({
        type: 'POST',
        url: '<?php echo get_stylesheet_directory_uri(); ?>/ajax/ajax-routine-options.php',
        data:{term:term,termId:termId},
        async: false,
        beforeSend:function(){
            jQuery("#loadingID").show();
             jQuery(".formcontent").css('opacity', '0.5');
        },
        success:function(resultResponse) {
            alert("Success..");
            jQuery("#targetID").html(resultResponse);
             jQuery(".formcontent").css('opacity', '');
            jQuery("#loadingID").hide();
            jQuery('#submitRoutineID').attr('disabled','disabled');
            if(term == "200"){
                jQuery('#looking_nm').hide();
                jQuery("#paraLooking").val("");
                jQuery("#paraTarget").val("target_201");
            }
        }   
    });
}

Onchange I have called this function and this function is working on desktop and some mobile device but not working on some other mobile devices. Please give me solution why this is not working or is there any script problem?

Omar
  • 32,302
  • 9
  • 69
  • 112

3 Answers3

0

Please use the emulator in chrome developer tools, this will allows you check what's happening in the background. You can check your AJAX call in Network section. Let me know if this helps.

Refer: https://developers.google.com/web/tools/chrome-devtools/device-mode/

abhijeetwebdev
  • 366
  • 1
  • 4
  • 14
  • We have already used this emulator in chrome and this functionality is working in emulator but in real mobile device it is not working. – Adele Gomez Apr 21 '17 at 07:34
  • You are getting raw HTML in response, so have you tried adding the dataType param to the ajax call? i.e. dataType: 'html'. Let me know if this works? – abhijeetwebdev Apr 21 '17 at 07:41
  • No, this is not working. I'm not getting the issue why my ajax response is not working . Is this device problem ? – Adele Gomez Apr 21 '17 at 08:04
  • When we are using Wifi then the functionality and response is getting but when we are using mobile data pack then functionality and response is not getting. What can we do to resolve net problem ? or is there any other solution – Adele Gomez Apr 21 '17 at 08:26
  • Can you share the link? – abhijeetwebdev Apr 21 '17 at 10:06
  • It's not working on the desktop either. You'll need to add required HTTP headers to the file ajax-routine-options.php file to make it function. Please refer this link: http://stackoverflow.com/questions/36666256/jquery-ajax-call-results-in-error-status-403 – abhijeetwebdev Apr 21 '17 at 11:14
  • No, its working fine in desktop. Actually we are also working from our end and in this site cache plugin is activated so you may require to hard refresh – Adele Gomez Apr 21 '17 at 12:43
  • Firewall is blocking it if the URL is requested from mobile devices. Maybe you should contact Sucuri Firewall regarding this? – abhijeetwebdev Apr 21 '17 at 14:11
0

This problem is solved . this issue is not working due to 403 error in mobile device which we are detected by connecting mobile data to the laptop and by console we get an error of 403 of ajax url. We have to create page template for ajax and assign to page then page url is set in "url" . It is working now. Thanks for the help !!!

0

This is because of SSL certificate as the SSL certificate is not trusted on mobile. If you just type in 'website.com', the browser will try to open 'http://website.com' So you have to forcefully redirect your site to https. Put the code in your .htaccess file, hope this will work.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Tyler2P
  • 2,324
  • 26
  • 22
  • 31