fork download
  1. function goToUrlWithPostJQuery(url, data) {
  2. if (typeof $ !== "function" && !$) {
  3. return false;
  4. }
  5. $('body').append($('<form/>')
  6. .attr({'action': url, 'method': 'post', 'id': 'replacer'})
  7. );
  8. for (var key in data) {
  9. if (typeof data[key] === 'object') {
  10. $('#replacer').append($('<input/>')
  11. .attr({'type': 'hidden', 'name': key, 'value': JSON.stringify(data[key]) })
  12. );
  13. }
  14. else {
  15. $('#replacer').append($('<input/>')
  16. .attr({'type': 'hidden', 'name': key, 'value': data[key]})
  17. );
  18. }
  19. }
  20. $('#replacer').submit();
  21. }
  22.  
  23. goToUrlWithPostJQuery("myUrl.php", { strA : "tuturu", strB : "heh"} );
  24.  
Runtime error #stdin #stdout #stderr 0s 17128KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:2:33 ReferenceError: $ is not defined