0

okay I have a simple html form script I have tried so many way to post the data to Ajax and have Ajax echo each line out separately one after another but unfortunately what ever I have tried just don't work for me I am new to java and Ajax here's my html form if any one can show me any example scripts or sample way to make my script echo each line of the form separately 1 by 1 .

heres my html form

<html>
<body>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.js"></script> 
</head>
<form method="post">
    <div align="center">
        <textarea name="mp" cols="60" rows="10">0|1|2</textarea>
        <br />

        Delim:
        <input type="text" name="delim" value="|" size="1" />&nbsp;

        data1:
        <input type="text" name="mail" value="0" size="1" />&nbsp;

        data2:
        <input type="text" name="prx" value="1" size="1" />&nbsp;

    <input type="submit" value=" send " name="btn-submit" />
</div>
</form>
</body>
</html>

<?php

?>
4
  • show us the attempted ajax Commented Feb 9, 2014 at 21:58
  • 1
    I have no idea what you're asking. Show us the code for what you're trying and maybe we can help. Commented Feb 9, 2014 at 21:58
  • if you read my question I am asking people to point me in the write direction or show me example on how to incorporate it into my script Commented Feb 9, 2014 at 22:01
  • You seem to be confusing the programming language PHP with a client-server communication protocol for JavaScript (AJAX). And I also fear that a database backend may play into your problem. Please try to clarify what you are actually asking. As it stands right now your question makes little to no sense. Commented Feb 9, 2014 at 22:30

1 Answer 1

1

I am not quite sure what you are asking. But I created a jsfiddle for you: http://jsfiddle.net/JWkmQ/.

I basically added some script that aggregates the data and attempts to post them somewhere:

$('#doit').on('click', function() {
    var data = {};
    $('textarea').each(function() {
        data[this.name] = $(this).val();
    });
    $('[type="text"]').each(function() {
        data[this.name] = $(this).val();
    });
    console.log(data);
    $.post('http://example.com/datalistener', JSON.stringify(data));
});

Of course, you will need some code on the server side to handle the request. I would suggest you code yourself some nodejs backend like this: http://www.hongkiat.com/blog/node-js-server-side-javascript/.

Please stay away from PHP ;)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.