AJAX Form

47 views
Skip to first unread message

James L

unread,
Nov 9, 2014, 12:53:45 PM11/9/14
to polym...@googlegroups.com
What is the difference between response="" and on-core-response=""

How do I receive the response once the form is submitted through AJAX?

PHP:
<?php
//Capture all inputs - $request_body = file_get_contents('php://input');
echo 'Your email is subscribed to our mailing list.';
?>

HTML:
...
</form>
    <core-ajax id="ajax" method="POST" url="r.php" params="{{item}}" response="{{response}}"></core-ajax>
    <template repeat="{{response}}">{{data}}</template>
    {{response}}
<br>
  </template>
  <script>
    Polymer('add-node', {
      created: function() {
        this.item = {};
      },
      doSend: function() {
this.$.ajax.go();
      },
 handleResponse: function(e) {        //Don't seem to work?
console.log("You got mail!");
      }
    });
  </script>

Eric Bidelman

unread,
Nov 9, 2014, 4:36:38 PM11/9/14
to James L, polymer-dev
on-core-response="{{handleResponse}}" is using Polymer's on-* declarative event handling.

response="{{resp}}"  data binds core-ajax's published response property to a property `resp` that you can use elsewhere in the your app.

In your example, you're not defining a handler for the `on-core-response` so `handleResponse` is never called. Instead, you can define a `responseChanged` changed handler to know when the form was submitted.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/bdcb8f35-5e7c-46ff-a25f-72fddc0ad147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages