separator alternative (PHP and AJAX)

Posted on 2009-04-24
Last Modified: 2012-06-27
When the passwordconfirmation field is typed, I want not only to tell the user if password and passwordconfirmation are equal, but also tell the user if the email is in database. Right now, I am thinking about echoing one responseText with a separator (the vertical bar). I am thinking about data like "| || | || | || | | || | || |" happening next. What are the alternatives to a separator? For example, is there a way to echo an array???
Question by:locke1994
    LVL 5

    Accepted Solution


    Its not good to use your own separator in the response text. The best solution for this is to use JSON. json_encode() function will serialize your array and give you the JSON string.

    $arr = array ('a'=>'some text','b'=>2,'c'=>3,'d'=>4,'e'=>5);
    echo json_encode($arr);

    Then convert this  JSON string to  JSON object using Javascript eval() function.

    var JSONObj= eval('(' + responseText + ')');

    then to access value of 'a' use the below syntax



    Author Comment

    Man, thank you so much, that's exactly what I was looking for!

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now