Jump to content

funbinod

Members
  • Posts

    501
  • Joined

  • Last visited

Everything posted by funbinod

  1. hello all! i am trying to change texts on a div multiple times using jquery. for this i tried the following $('#clickme').on('click', function(e) { $('#msg').text('hello'); $('#msg').delay(500).text('First Change!'); $('#msg').delay(500).text('Second Change!'); }) but this olny displays directly the last option (i.e. 'Second Change!') and none of other. i wish them to change one by one with some delay. please guide me how can i achieve this. thank u in advance...
  2. thank u for this @dsonesuk.. but sorry! there was a mistake in my html form. the input name="m" is "text" type not "file" type. so, i think, u've to write some extra line on setting formdata. i tried to revise the code accordingly. please tell me if it is correct or not-- $(document).ready(function(e) { function submIt(e) { e.preventDefault(); var formdata = new FormData($('#pgm').get(0)); formdata.set($(this).attr('name'), $('input[type=file]')[index].files[0]); $('input').attr('disabled', 'disabled'); $.ajax({ url: "process.php", type: 'POST', data: formdata, contentType: false, cache: false, processData: false, success: function(result) { $('input').removeAttr('disabled'); if ($(result).filter('#success').text() == '' || $(result).filter('#success').text() == 'NO') { $('input, textarea').css('border', '2px solid red'); alert('return but error!'); alert($(result).filter('#msg').text());/**/ } else { $('input').removeAttr('disabled'); $('input, textarea').css('border', '1px solid green'); alert('return success'); alert($(result).filter('#msg').text()); $('#adit').empty(); $('#adit').load('pgmadd.php'); } $('#pgm :input').attr('disabled', true);// moved here by dsonesuk }, error: function() { $('input').removeAttr('disabled'); $('input, textarea').css('border', '2px solid red'); alert($(result).filter('#msg').text());/* */ } }); } $('#pgm').on('submit', function(e) { if ($('#hdng').val() == '' || $('#desc').val() == '') { if ($('#hdng').val() == '') { alert('Program name is blank!'); $('#hdng').select(); $('#hdng').css('border', '2px solid red'); } if ($('#desc').val() == '') { alert('Description is empty!'); $('#desc').css('border', '2px solid red'); $('#hdng').select(); } } else { submIt(); } }); })
  3. thank u. last one: does this upload file??
  4. i tried "$.post" in stead of "$.ajax" and the form is sent to target properly. but i faced another problem with file upload. the response from php says "$_FILES['img']" to be undefined index.
  5. because i'm uploading image also. so i thought i need to specify this, as i need this as i need in html form. and i read the same on some tutorials about sending image using ajax
  6. here is the html form <form id="pgm" name="pgm" method="post"> <input type="file" id="m" name="m" value="pgmadd" hidden="hidden" /> <span>Program:</span> <span><input type="text" id="head" name="head" placeholder="Name of Program" /></span><br /><br /> <span>Image:</span> <span><input type="file" id="img" name="img" /></span><br /><hr /> <span>Description:</span> <span><textarea rows="10" id="description" name="description" placeholder="Description of Program"></textarea></span><br /><br /> <input id="submit" name="submit" value="Submit" type="submit" /> </form> and here is the ajax request <script> $(document).ready(function(e) { function submIt() { $('input').attr('disabled', 'disabled'); $.ajax({ url:"process.php", dataType:"text", processData:false, contentType:false, enctype:"multipart/form-data", type:'POST', data: { m: 'pgmadd', hdng: $('#head').val(), img: $('#img').val(), description: $('#description').val() }, success: function(result) { $('input').removeAttr('disabled'); if ($(result).filter('#success').text() == '' || $(result).filter('#success').text() == 'NO'){ $('input, textarea').css('border', '2px solid red'); alert('return but error!'); alert($(result).filter('#msg').text()); } else { $('input').removeAttr('disabled'); $('input, textarea').css('border', '1px solid green'); alert('return success'); alert($(result).filter('#msg').text()); $('#adit').empty(); $('#adit').load('pgmadd.php'); } }, error: function() { $('input').removeAttr('disabled'); $('input, textarea').css('border', '2px solid red'); alert('error with error'); alert($(result).filter('#msg').text()); } }); } $('#submit').on('click', function(e) { submIt(); }); }) </script> i again remind. this is working properly when i use "type: GET".
  7. i thought if it would work if i use newer version. it was (and still is) the same while using 1.8.2
  8. there is nothing in the response. what it displays is the only message from the php when it is not called from proper $_POST['m'].
  9. in the network tab of developer tool, it says the status is 200 (i.e. ok) but i found that the ajax is not sending any data to the php (or php is not receiving the data from ajax).
  10. anybody here? i'm still stuck in this problem.. please help!
  11. its from rest of the code that is used to upload the image. its like: $img = $dir . basename($_FILES["img"]["name"]); edit: and the "$dir" depends on the value according to the value of "$m". its also defined above on the rest of the code.
  12. its obviously $_POST here is the PHP $m = $_POST['m']; if ($m == 'pgmadd') { $head = ($_POST['hdng']); $descr = ($_POST['description']); $usenow = 'Y'; $sql = $mysqli->prepare("INSERT INTO programs (head, description, status, filepath) VALUES(?,?,?,?)"); if (!$sql) { echo '<div id="success">NO</div>'; echo '<div id="msg">Error: '.$mysqli->error.'</div>'; } else { $sql->bind_param('ssss', $head, $descr, $usenow, $img); $msg = "Added Successfully!"; } if ($sql->execute()) { echo '<div id="success">YES</div>'; echo '<div id="msg">'.$msg.'</div>'; } else { echo '<div id="success">NO</div>'; echo '<div id="msg">Error: '.$mysqli->error.'</div>'; } }
  13. the w3c validator says there are 71 errors in your page. one of them is in line 213. style="font-size: 14px; "margin-left: 25px; margin-right: 25px;" here is the closing double inverted comma (") in between the style attribute. try deleting this. and correct all other errors pointed by w3c validator.
  14. hello all. i got confused in sending form data using ajax. when i send data using ajax with GET type, it works fine. but when i send it with POST type it doesn't work here is the ajax i use : $(document).ready(function(e) { function submIt() { $('input').attr('disabled', 'disabled'); var formData = new FormData(document.getElementById("pgm")); $.ajax({ url:"process.php", dataType:"text", processData:false, contentType:false, enctype:"multipart/form-data", type:'POST', data: formData, success: function(result) { $('input').removeAttr('disabled'); if ($(result).filter('#success').text() == '' || $(result).filter('#success').text() == 'NO'){ $('input, textarea').css('border', '2px solid red'); alert($(result).filter('#msg').text()); } else { $('input').removeAttr('disabled'); $('input, textarea').css('border', '1px solid green'); alert($(result).filter('#msg').text()); $('#adit').empty(); $('#adit').load('pgmadd.php'); } }, error: function() { $('input').removeAttr('disabled'); $('input, textarea').css('border', '2px solid red'); alert($(result).filter('#msg').text()); } }); } $('#submit').on('click', function(e) { if ($('#head').val() == '' || $('#desc').val() == '') { if ($('#head').val() == '') { alert('Program name is blank!'); $('#head').select(); $('#head').css('border', '2px solid red'); } if ($('#desc').val() == '') { alert('Description is empty!'); $('#desc').css('border', '2px solid red'); $('#head').select(); } } else { submIt(); } }); }) it is working properly when i use < type: 'GET' > Edit: I'm using jQuery 1.8.2 please guide me. thanks in advance.
  15. i found out that its not by adding $stmt->store_result() AFTER bind_result(). but its solved by adding $stmt->store_result() BEFORE bind result. somewhere on the web i read that when selecting a longtext() field, we have to use store_result before bind_result. and now the problem is solved. thank u all for being with me to solve this problem...
  16. getting more interesting.. it works fine for all columns when i use simple "$mysqli->query". but when i use prepared statement, it doesn't work for the column - description, even selecting only that coulmn
  17. it echoed 1 and 2. this means it stopped while binding result??
  18. its still not working using backticks `description`. what could be the possible reason for not working?? its worrying me... edit: the column's type is set to longtext()... edit: i even tried changing the column's name... still no improve...
  19. @Don E ---------------- the problem is only that it doesn't work when i select 'description' column. otherwise it works fine. using the column even doesn't show any error. it just doesn't work without showing any error. i even tried getting error, if any, on execute (i.e., if(!$stmt->execute()) {echo $mysqli->error;} ) but it didn't show any error msg. ========================== is 'description' a reserved word?
  20. yes! nothing is returning false.
  21. hello all! i was writing a mysql prepared statement on php and i stuck at one point that made me feel something interesting. the following query works fine only after i remove the column 'description'. but selecting the column doesn't work and shows no error. if($stmt = $mysqli->prepare("SELECT item,sid,catid,oqty,unitid,sprice,pprice,description FROM stock WHERE (icode=? or bcode=?) AND cid=?")) { $stmt->bind_param('ssi', $icode, $icode, $cid); $stmt->execute(); $stmt->bind_result($item,$sid,$catid,$oqty,$unitid,$sprice,$pprice,$description); $stmt->fetch(); $stmt->close(); $stmt->free_result(); } else { echo 'Error: '.$mysqli->error; } and yes! these is existence of column named 'description'. i'm stuck at this point. please guide me why is this happening.
  22. yes but, i thought, there could be some special method to send SAME DATA to multiple pages using single ajax request in stead of writing multiple ajax requests for SAME DATA. is there any special method??
×
×
  • Create New...