0

I'm having a bit of difficulty conceptualising this: I have some data stored to a button:

var input2 = '<button id="viewmap1" class="viewmap">Find on Map</button>';
        //MAKE DATA
        $(input2).data('longlat', coords);

Now I want to send that data to another page. I understand I am to use jQuery post, eg:

$.post("test.html", { func: "getNameAndTime" },
  function(data){
    alert("Hello"); 
  }, "json");

But im not entirely sure how to go about it. Can any one point me in the right direction? Thanks

3
  • when you send data ? after click somthing element or another? Commented Aug 2, 2012 at 6:43
  • can you update your question and adding some code again, example click button code,and what doyou want if data is sended to be better answer..? Commented Aug 2, 2012 at 7:05
  • for what you want to send data to another page?\ Commented Aug 2, 2012 at 7:11

2 Answers 2

2

Sending data to a different page isn't as simple as it sounds. If it were simple, crackers could manipulate all the other pages that you currently have open in browser tabs.

When you call $.post(), that just sends data to the server, not to another page. The URL is a way to tell the server how to process the data but it doesn't magically connect you to the browser tab/window which has test.html open.

The usual solution is to use a single page which contains the button and the elements to display the results (a.k.a "view"). You send the POST request and then update the view in the callback function.

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

Comments

0
$(input2).on('click', function(){
 // do your post stuffs
});

then need to trigger the button click

$(input2).click();

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.