0

Im trying to create a bookmarklet that allows users to post a lot of cross domain data to a php script and get a response from the php script using jquery. What is the best way to do this

1
  • Would it be possible for you to make your PHP script to parse JSON data? You can post JSON via jQuery to your PHP script and then just parse that. $.ajax() or $.post() would work here.. Commented Sep 7, 2011 at 13:36

3 Answers 3

3

Your best shot will be to use JSONP:

JSONP or "JSON with padding" is a complement to the base JSON data format, a pattern of usage allowing a page to request data from a server in a different domain. JSONP is a solution to this problem, forming an alternative to a more recent method called Cross-Origin Resource Sharing.

jQuery implements JSONP. Try and test this code:

$.ajax( {
  url: 'http://…',
  dataType: 'jsonp',
  complete: function(xmlHttpReq, textStatus) {…}
});
Sign up to request clarification or add additional context in comments.

Comments

1

I recommend checking out JavaScript: Use a Web Proxy for Cross-Domain XMLHttpRequest Calls

Comments

0

Tricky because Cross Site Scripting gets blocked by most browsers. My solution was to write the data to a file and then access that file from php. Pass the data through a file in other words.

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.