Making Post request for sending data using AJAX or By Using Ember Data Tutorial- Ember with rails post request - UCS - Unleash-Coding-Skills

Friday, 17 August 2018

Making Post request for sending data using AJAX or By Using Ember Data Tutorial- Ember with rails post request - UCS




Hey guys, are you new Ember ­čśŐsearching for how to connect the Ember front end to your backend.
Here you can be cool and follow the next few lines you will know how to send data from ember to backend in our example I am taking rails as a  backend.

First I will show the code how to make a post request from ember using AJAX with a promise. Here I am using Ember 2.12.

Here is the ajax request you can make from a component.js file or from the controller.js file.

    $.when($.ajax ({
        type: 'POST',
        url:'http://localhost:3000/notes',
        data: {note:{title:title1,description:description1}},
      })).then(function(result){
        console.log(result);
      }).catch(function(err){
        console.log(err);
      });

Here you can observe that first, you need to mention the type: post or get or put,
next to the URL. Here the URL is the response JSON from the backend i.e., the URL from where you can obtain your data from backend to frontend or the URL through which you can send to the backend and data is the JSON that is required by the format of your backend.

So that you will get a response after successful submission of the post request to the backend.

Now we can see how we can make a post without AJAX using EMBER DATA.

. . . .

  sendData(title1,description1,date1) {
      function accept(res)
{
console.log(res)
}
function failure(err)
{
console.log(err);
}

 var request = $.post("/notes", {note:{title:title1,description:description1,date:date1,status:"done"}})
 request.then(accept.bind(this), failure.bind(this));

Here, first of all, you made a request using the using a promise to the backend and later we are handling the success and failure cases in the promise.

Note:
All the above request can be written in actions in the component or controller and you can make the corresponding actions function and execute the request.

You can get a how to submit the form data successfully to DB using backend tutorial using AJAX or ember-data within next week.Hope we produce the best tutorials as possi ble.Bookmark us and see for this tutorial in the next week.


Happy Coding.........

Tags:

Making Post request for sending data using AJAX or By Using Ember Data Tutorial- Ember with rails post request , HTTP requests in ember,Connecting ember with rails,ember frontend request,EMBER 2.2 requests,EMBER connecting to backend.

24 comments:

  1. Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing.
    ExcelR Data Analytics courses

    ReplyDelete
  2. Very nice blog here and thanks for post it.. Keep blogging...
    ExcelR data science training

    ReplyDelete
  3. Attend The Analytics Training Institute From ExcelR. Practical Analytics Training Institute Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Analytics Training Institute.
    ExcelR Analytics Training Institute

    ReplyDelete
  4. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
    ExcelR data science course in mumbai

    ReplyDelete
  5. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    data analytics courses

    ReplyDelete

  6. I have been reading for the past two days about your blogs and topics, still on fetching! Wondering about your words on each line was massively effective. Techno-based information has been fetched in each of your topics. Sure it will enhance and fill the queries of the public needs. Feeling so glad about your article. Thanks…!
    selenium training in chennai
    selenium online courses best selenium online training
    selenium testing training
    selenium classes

    ReplyDelete
  7. Nice information, valuable and excellent work, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here. data science course

    ReplyDelete
  8. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
    data analytics course mumbai

    ReplyDelete
  9. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    data analytics training in hyderabad
    business analytics course
    data science course

    ReplyDelete
  10. Great Article. Thank you for sharing! Really an awesome post for every one.
    Digital Marketing Course In Kolkata
    Web Design Course In Kolkata

    ReplyDelete
  11. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.

    business analytics course

    data analytics courses

    data science interview questions

    data science course in mumbai

    ReplyDelete
  12. It’s difficult to find knowledgeable people on this subject, but you seem like you know what you’re tech talking about! Thanks

    ReplyDelete
  13. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.

    Simple Linear Regression

    Correlation vs covariance

    KNN Algorithm

    Logistic Regression explained

    ReplyDelete
  14. Cool stuff you have and you keep overhaul every one of us


    data science interview questions

    ReplyDelete
  15. Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple Linear Regression
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  16. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.

    Simple Linear Regression

    Correlation vs Covariance

    ReplyDelete
  17. Attend The Data Science Training Bangalore From ExcelR. Practical Data Science Training Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Science Training Bangalore.
    Data Science Training Bangalore

    ReplyDelete
  18. of luck for all your blogging efforts.
    a href="https://www.excelr.com/data-analytics-certification-training-course-in-pune/"> Data Analytics Course in Pune/">It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!
    I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…

    ReplyDelete
  19. The content that I normally go through in the recent times is nothing like what you have on paper. Thank you for writing this!
    Data Science training in Mumbai
    Data Science course in Mumbai
    SAP training in Mumbai

    ReplyDelete