Advanced Search

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Displaying php validation results through javascript

  1. #11
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,629
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    with your ajax call, you're trying to treat the return value as html. If you specify that you're expecting json, you can use it like json:
    Code:
    $.ajax({
        type:     'POST',
        url:      $('#login').attr('action'),
        data:     $('#login').serialize(),
        dataType: 'json',
        success:  function( data ){
                      var errMsg = data.error_messages.error[0];
                      $('#results').html( '<p>The error message is: <b>'+errMsg+'</b>' );
                  }
    });
    Quote Originally Posted by letom
    But when we submitting it through ajax it is not going to the below coding , that is the problem iam getting some more results with the error message
    I'm not sure what you mean by this.
    Last edited by traq; 05-19-2013 at 07:53 PM. Reason: fixed typo in code
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  2. #12
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by traq View Post
    with your ajax call, you're trying to treat the return value as html. If you specify that you're expecting json, you can use it like json:
    Code:
    $.ajax({
        type:     'POST',
        url:      $('#login').attr('action'),
        data:     $('#login').serialize(),
        dataType: 'json',
        success:  function( data ){
                      var errMsg = data.error_messages.error[0];
                      $('#results').html( '<p>The error message is: <b>'+errMsg+'</b>' );
                  }
    });
    Quote Originally Posted by traq
    Quote Originally Posted by letom
    But when we submitting it through ajax it is not going to the below coding , that is the problem iam getting some more results with the error message
    I'm not sure what you mean by this.
    That is FYI only, to understand the php coding / i mean putting some more equal code like that in javascript will produce correct result.
    Eg .. foreach provides a way to iterate over arrays in php / $.each is some more similar in java script

    I will let you know here the result.... But i tried previously some more related to that, but not producing the accurate one
    Last edited by traq; 05-19-2013 at 07:56 PM. Reason: fixed quote tags
    You will know the truth, and the truth will set you free (John 8:32)(The truth is about the only begotten son of GOD.....When you feel you are alone for facing your problems, God will never leave you by your own You are important for God

  3. #13
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,629
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    typo in my code. This is the correct version:
    Code:
    $.ajax({
        type:     'POST',
        url:      $('#login').attr('action'),
        data:     $('#login').serialize(),
        dataType: 'json', 
        success:  function( data ){
                      var errMsg = data.error_messages.error[0];
                      $('#results').html( '<p>The error message is: <b>'+errMsg+'</b>' );
                  }
    });
    Last edited by traq; 05-19-2013 at 07:57 PM.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  4. #14
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default

    Yes .. I am going to notify that...
    but not a fruitful one ..
    You will know the truth, and the truth will set you free (John 8:32)(The truth is about the only begotten son of GOD.....When you feel you are alone for facing your problems, God will never leave you by your own You are important for God

Similar Threads

  1. Javascript results in text boxes
    By Johny Appleseed in forum JavaScript
    Replies: 1
    Last Post: 08-30-2012, 09:04 AM
  2. How to get my javascript results to display
    By forum_amnesiac in forum HTML
    Replies: 0
    Last Post: 05-23-2009, 09:17 AM
  3. Mixed results with javascript.
    By max_power in forum JavaScript
    Replies: 1
    Last Post: 04-24-2009, 11:58 AM
  4. Save javascript results
    By ptera in forum Looking for such a script or service
    Replies: 0
    Last Post: 03-26-2009, 04:35 PM
  5. Displaying serach results in a different way
    By stefaneh in forum Looking for such a script or service
    Replies: 1
    Last Post: 07-30-2007, 10:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •