Tim Wilkinson
Tim Wilkinson

Reputation: 3791

jQuery load 'POST' error

I am just trying to load the content of one div into another onClick, but i get an error requesting i use the POST request,

$("#button").click(function(){
     $('#slide1').load('#slide2');
});

half working example at http://jsfiddle.net/9hnZx/

Still new to the whole jQuery front so please be patient if this is a stupid question! Thanks!

edit. Thanks to all who answered, really helped, except the example i gave is working in jsfiddle but i cant get working in the website where it is required, http://bettondesignwork.co.uk/tim/j3mobile/ anyone got any clues? jQuery is loading just fine!

Upvotes: 1

Views: 67

Answers (4)

Waqas Ghouri
Waqas Ghouri

Reputation: 1140

jQuery Code

$("#button").click(function(){
         //first get the send div text
        var secondDiv = $("#slide2").text();
        var firstDiv = $("#slide1").text();
         // slide 1 value

         $('#slide2').text(secondDiv+" "+firstDiv);
    });

Upvotes: 0

lonesomeday
lonesomeday

Reputation: 237905

Other answers suggest copying the HTML of one element to another. This is a bad idea, for the reasons illustrated in this answer. Instead, copy the DOM elements:

$("#button").click(function(){
    $('#slide1').html($('#slide2').contents());
});

For documentation on this, see the API reference pages for html and contents

Upvotes: 1

Cris
Cris

Reputation: 13351

try instead

 $("#button").click(function(){
         $('#slide1').html($('#slide2').html());
    });

Upvotes: 0

user1343875
user1343875

Reputation:

Try:

$("#button").click(function(){
    $('#slide1').html($('#slide2').html());
});

Upvotes: 1

Related Questions