SHOW:
|
|
- or go back to the newest paste.
| 1 | $jQ('#searchform').submit(function(e){
| |
| 2 | //disable original action | |
| 3 | e.preventDefault(); | |
| 4 | value2_1 = { a: 'a',b: 'b' };
| |
| 5 | value2.push(value2_1); | |
| 6 | var values = { 'action':'my_new_ajax', 'value1':value1, 'value2':value2};
| |
| 7 | //ajax request | |
| 8 | $jQ.ajax({url:ajaxurl,type:'POST',data:values,success: function(data) { //aAnswer
| |
| 9 | var answer = $jQ.parseJSON(data); | |
| 10 | if ( answer.set_globals == "ok" ){alert("Globals are set"); } else { alert("Globals not set :("); }
| |
| 11 | //grab current url w/ query vars | |
| 12 | var redir = window.location.href; | |
| 13 | //redirect to the current url to preserve origanal submit functionallity | |
| 14 | //NOTE: This redirect will cancel the above alerts...just comment out the line below to stop redirection | |
| 15 | window.location = redir; | |
| 16 | } | |
| 17 | }).fail(function(errorThrown) { alert('error'); console.log(errorThrown); });
| |
| 18 | }); |