开发者

Bookmarklet pulls data from current page then injects it in a remote page

I'm working with a script that is scraping data from my currently viewed page corr开发者_开发技巧ectly. Now I need to know the syntax that lets me inject (and submit) those values into a form found on a different page.

code for the bookmarklet:

javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);var%20s=document.createElement('script');s.setAttribute('src',%20'http://juststeve.com/test.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);

can run against: http://juststeve.com/testData.htm needs to inject it to the form: http://juststeve.com/testform.htm

thankx


You might want to take a look at: scripting a google docs form submission


Since you seem to be using jQuery to perform the data harvesting and submission, you should first check the jQuery documentation. There you'll find how to use $.ajax to submit data (using the data parameter).

In short, what you have to do is replace

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this"  },

with

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this", "orderDate": orderDate, "email": email, "customerID": customerID },

meaning that the AJAX POST request will give the server 3 extra parameters in the request with the values I'm guessing you want to submit. How you deal with retrieving such values in the server side will depend on the server side language/stack you're using.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜