tirenweb
tirenweb

Reputation: 31749

jQuery/post(): the URL called is not what I expected

I have a link at http://myweb.localhost/miembros/id/1/mensajes. When I click that link, the code below is called:

<script type="text/javascript">

   $('.switch_leido').click(function(){

     $.post('mensaje/cambiarEstadoLeido',
            {id:$(this).data('leido')},
            function(){
              alert("fasfsf");
            }
     );
   });

and I get this error:

POST http://myweb.localhost/miembros/id/1/mensaje/cambiarEstadoLeido 404 (Not Found)

Instead, I expected http://myweb.localhost/mensaje/cambiarEstadoLeido was called but no..:S

What should I do?

Javier

Upvotes: 1

Views: 59

Answers (2)

John Hartsock
John Hartsock

Reputation: 86902

Your path is set relative. Use a "/" in front to reference the root of the web site

 $.post('/mensaje/cambiarEstadoLeido', ...

Upvotes: 2

owenmelbz
owenmelbz

Reputation: 6584

Use an absolute path? maybe change to

 $.post('/mensaje/cambiarEstadoLeido',

Upvotes: 1

Related Questions