I need a user to navigate to a certain page that has a certain div full of useful text. Then click my bookmarklet and send the text in that div back to my server, which is different from the current domain. I have successfully inserted jQuery on the bookmarklet click and selected the text. Now I need to figure out a way to send that text cross domain to my server. I tried JSONP with jQuery and my text is too long for the url. My second idea was to open up a new window and load a page from my domain, and then somehow insert the selected text into the new window, after which the user could click submit and POST that data to my server. This didn't work for javascript cross-site reasons. Anyone have any experience with this or ideas for doing this? Thanks.
A:
Generate a form (with DOM) and POST the data (you might want to target an iframe, but it will be fire and forget).
David Dorward
2010-02-03 21:01:33
Could you go into a bit more detail how you would be able to POST from a domain other than the server's?
agoessling
2010-02-03 21:30:42
There are no restrictions on where a form can post to. Only on where you can read data from using JS. Just use the submit method of the form element.
David Dorward
2010-02-03 21:39:06
I am running into a problem where I try to set the value of an text input to a very long string. This makes the server return a 403 Forbidden error. If I shorten the string It works as expected. Is there anyway to send long text strings?
agoessling
2010-02-04 03:28:31
Fix your server so it accepts very long strings in the POST data.
David Dorward
2010-02-04 07:17:16
Is it possible to prevent the page redirect to the php file that is processing the POST? and in that case, can you still get a response back from the server? How does one target an iframe?
agoessling
2010-02-04 21:36:39
Yes - by targeting an iframe. No, you can only fire and forget. With the target attribute.
David Dorward
2010-02-04 23:10:35