Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $jQ('#searchform').submit(function(e){
- //disable original action
- e.preventDefault();
- value2_1 = { a: 'a',b: 'b' };
- value2.push(value2_1);
- var values = { 'action':'my_new_ajax', 'value1':value1, 'value2':value2};
- //ajax request
- $jQ.ajax({url:ajaxurl,type:'POST',data:values,success: function(data) { //aAnswer
- var answer = $jQ.parseJSON(data);
- if ( answer.set_globals == "ok" ){alert("Globals are set"); } else { alert("Globals not set :("); }
- //grab current url w/ query vars
- var redir = window.location.href;
- //redirect to the current url to preserve origanal submit functionallity
- //NOTE: This redirect will cancel the above alerts...just comment out the line below to stop redirection
- window.location = redir;
- }
- }).fail(function(errorThrown) { alert('error'); console.log(errorThrown); });
- });
Add Comment
Please, Sign In to add comment