Send single input with ajax/jquery/php

horbassn

New Member
I'm new to jQuery / AJAX.I'm trying to send single input with jquery/ajax/php.LIVE EXAMPLEBut, after pressing submit nothing is happening, where is my error?Any help much appreciated.HTML:\[code\]<form action="submit.php"> <input id="number" name="number" type="text" /> <input id="submit" name="submit" type="submit" /></form>\[/code\]JQUERY / AJAX:\[code\]$(document).ready(function(e) { $('input#submit').click(function() { var number = $('input[name=number]'); var data = 'http://stackoverflow.com/questions/6890533/number=' + number.val(); $.ajax({ url: "submit.php", type: "GET", data: data, cache: false, success: function(html) { if (html == 1) { alert('wyslane'); } else { alert('error'); } } }); return false; });});\[/code\]PHP:\[code\]<?php $mailTo = '[email protected]'; $mailFrom = '[email protected]'; $subject = 'Call Back'; $number = ($_GET['number']) ? $_GET['number'] : $_POST['number']; mail($mailTo, $subject, $number, "From: ".$mailFrom);?>\[/code\]
 
Top