0
$('#tabPublish').click(function(){

        $('#columnRight').load('/pages/publish/');

        tabArray.push({'linkId': 'tabPublish', 'id': 'columnRight','url': '/pages/publish/',});

        return false;

});

I'm trying to push loaded content into an array as as string, but i cant seem to get past this point. I'm trying to do it so when the user clicks a previously loaded tab the code doesnt carry out a .load() again, it just grabs it from the array!

1
  • Don't you want to use $.ajax? Commented Sep 19, 2011 at 15:03

2 Answers 2

1

You can pass a callback to .load():

$('#columnRight').load('/pages/publish/', function(response) {
    tabArray.push({
        linkId: 'tabPublish', 
        id: 'columnRight',
        url: '/pages/publish/',
        content: response     // assuming you want to do something like this
    });
});
Sign up to request clarification or add additional context in comments.

Comments

0

When you call jQuery's load method the response string should represent valid HTML that is then appended into the #tabPublish element. By the time the method is done what you've got is a whole bunch of new HTML inside the #tabPublish element.

It seems like what you're trying to do would require $.ajax, not $.load. Am I correct to assume that the object you're passing into the push method is what you're expecting the server to return to you perhaps as JSON during the load method?

Can you provide an example of a response you expect to get from the server?

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.