funbinod

Members
  • Content count

    451
  • Joined

  • Last visited

Community Reputation

3 Neutral

About funbinod

  • Rank
    Member
  • Birthday 05/12/1983

Previous Fields

  • Languages
    HTML, PHP, JAVASCRIPT

Profile Information

  • Gender
  • Location
    Nepal

Contact Methods

  • Yahoo
    funbinod
  • Skype
    binod.anuj
  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. what is the condition to win a game?
  12. 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.
  13. 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>'; } }
  14. 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.
  15. 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.