Hack Forums
Send form using Jquery without a form - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: Send form using Jquery without a form (/showthread.php?tid=2962986)



Send form using Jquery without a form - zomgwtfbbq - Oct 22, 2012

Let's say I have images that have a numeric id, when someone clicks the image I want to POST the id in variable iCFG. I'm forced to make a POST form otherwise I have to change lots of things to the GET method.

I don't want the result to be returned on the same page, but just open the page configuration(same as you would send an HTML form).

I've tried several solutions that didn't work out as I expected eg:
Code
    $(".selectinterface img").click(function(){
        $.post("configuration.php", { iCFG: $(this).attr('id') } );
    });

Any help would be greatly appreciated.


* - node.js - Oct 22, 2012

That should work unless you have an error. Did you try debugging it?


* - zomgwtfbbq - Oct 23, 2012

Thanks for your reply.

The example sends the post variable, but it doesn't change the browser location to configuration.php and that's the thing I want like I said.

Quote:I don't want the result to be returned on the same page, but just open the page configuration(same as you would send an HTML form).



* - n0pcode - Oct 23, 2012

I think this solves your problem: http://stackoverflow.com/questions/8389646/send-post-data-on-redirect-with-javascript-jquery


* - zomgwtfbbq - Oct 23, 2012

Thanks a lot kript0x, exactly what I needed! ;)