Page 1 of 1

jQuery doesn't work

PostPosted: 02. August 2016 15:33
by Ciberbago
I am using a jquery script but when I open the page in localhost it doesn't do anything.

The script is in a file named: script.js and the code is:

Code: Select all
var inicio=function () {
   $(".cantidad").keyup(function(e){
      
      if($(this).val()!=''){
         if(e.keyCode==13){
            var id=$(this).attr('data-id');
            var precio=$(this).attr('data-precio');
            $(this).parentsUntil('.producto').find('.subtotal').text('Subtotal: '+(precio*cantidad));
         }
      }
   });
}
$(document).on('ready',inicio);


I call it from another file like this:

Code: Select all
<html>
<head><title>Carrito - CiberPC</title>
<link href= "estilos.css" rel="stylesheet" type= "text/css">

[b]<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="script.js"></script>[/b]

</head>
<body>

etc....


Can you help me, guys? Thank you.

Re: jQuery doesn't work

PostPosted: 02. August 2016 15:38
by Altrea
JQuery is running on the clients browser only.
Xampp components don't touch it so it cannot be a XAMPP problem.

Re: jQuery doesn't work

PostPosted: 03. August 2016 05:26
by Ciberbago
Altrea wrote:JQuery is running on the clients browser only.
Xampp components don't touch it so it cannot be a XAMPP problem.


So... What can it be? :c

Re: jQuery doesn't work

PostPosted: 03. August 2016 11:22
by JJ_Tagy
Usually browsers treat localhost as intranet so the settings are different. Perhaps the browser is disabling the cross site script. As Altrea mentioned, this is not an XAMPP issue.

Re: jQuery doesn't work

PostPosted: 03. August 2016 18:58
by Ciberbago
JJ_Tagy wrote:Usually browsers treat localhost as intranet so the settings are different. Perhaps the browser is disabling the cross site script. As Altrea mentioned, this is not an XAMPP issue.


Then what can I do?

Re: jQuery doesn't work

PostPosted: 03. August 2016 19:00
by Altrea
Debug your script and browser , request, response, etc.
This is the wrong place to teach you how to debug JavaScript scripts on local environments.
We cannot do anything to help you here, sorry.