0

I just get {"error": "Please use POST request"} when I run this

$("#ricomporreclick").click(function () {
    $("#film").css('visibility', 'hidden');
    $("#ricomporre").css('visibility', 'visible');
});

What's wrong with the code? I'm tring to change the selector without page being reloaded.. when the click is triggered #film should be display:none and #ricomporre should be visible.

http://jsfiddle.net/8Ndba/

4 Answers 4

2

just put return false at end of the code block.

Updated Your Fiddle

Sign up to request clarification or add additional context in comments.

Comments

1

Try to use event.preventDefault() to prevent the default functionality of the anchor tag,

$("#ricomporreclick").click(function (e) {
    e.preventDefault()
    $("#film").css('visibility', 'hidden');
    $("#ricomporre").css('visibility', 'visible');
});

DEMO

1 Comment

@DioCane Just now checked your page, Wrap that code inside $(document).ready().! And let me know whether it is working or not.?
0

Change your anchor so the URL doesn't do anything:

<a href="javascript:void()" id="ricomporreclick">HERE</a> 

DEMO

Comments

0

You need to stop the link from redirecting by using the preventDefault method. I've edited the fiddle to show this

$("#ricomporreclick").click(function (e) {
    $("#film").css('visibility', 'hidden');
    $("#ricomporre").css('visibility', 'visible');
    e.preventDefault();
});

What was happening previously was that it was correctly changing the visibility, but then the link was reloading the page causing the css to be reset to the stylesheet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.