I am using Tag functionality of select 2 in my spring application and hibernate to save it. I am using the AJAX call to save this form.
Till here it is working fine.
My problem is:
How can I populate the data from DB and display it in screen as tag so that user can update it. (this data has id and text)?
How can I save this data in DB using AJAX call. Basic form is saving but for this select2 data I am able to get only keys. I need proper Entity so that I can save/update it directly in DB?
an example will be very much appreciated. right now, I am not putting my code there. Please comment n this post if you want me to post any code.
FYI: I am new in spring and hibernate.
Related
I have just started out working with JS and I've managed to post data from a MySQL db to the website using node.js, jade and plain JS.
Now I'm trying to do the other way around, i.e. getting data from the website, to the JS code and then inserting it into the db.
What I'm thinking is simply making a textfield with a button. When I fill the textfield and press the button it is collected by the JS script and the inserted to the DB.
I am however having problems with Jade and the listener and I'm unable to even do a console.log using the listener.
This is what I've got so far in my .jade file.
extends layout
script.
var something = function() {
console.log('something')
}
block content
button(onclick='something()') Click
The website renders nicely, but nothing is printed when I click the button.
If someone could give a hint on how to fetch the data in my .js file that would also be appreciated.
In the context of the WWW there are two places that JavaScript can run.
On the server, e.g. with node.js
On the browser, embedded in a <script> element
Since you want to put the data into a database on the server, you want to go with option 1. So don't use a <script> element.
Use a <form> (you could use client side JS to read the data from the form and send it to the server (Ajax) but that seems overcomplicated for your needs and should be layered on top of a plain HTML solution if you were to go down that route).
form(action="/myendpoint" method="post")
label
| Data
textarea(name="foo")
button Submit
Then you just need to write server side code to retrieve that. The specifics of that will depend on how you are implementing the HTTP server in Node.
The question How do you extract POST data in Node.js? provides some starting points.
I have a problem with project iam working on. In one route(program/messages) of my application, user can create and edit messages(using ckeditor textarea). These messages are saved in database. On another route(program/display) the application generates html site with messages(retrieved from database) created by user. The problem is that i need to update the display view(without site refresh ofc), when user change something in messages data(edit, or create new / delete). Any solution? Iam using codeigniter for backend.
Your view page must contain an ajax script. Which will check for database changes upon certain interval. That's all. I think ajax is new for you. Please grab a bit more AJAX concept. It's pretty handy ..
You can see W3school --
http://www.w3schools.com/ajax/default.asp
If you are in a hurry .. then ..
https://thenewboston.com/videos.php?cat=61
You can use
Jquery ajax() function
Javascript setInterval() function
Set the interval to certain time which will execute the ajax function to see if there is certain change in the database. if there is a change then update the view in success of ajax call.
There is another solution by using triggers in the database. But I am not quite sure about this.
I am using laravel framework, I have one index page in that I am retrieving dynamic table from another page by ajax(using div). Then now I am allowing user to edit table values so now I want to send modified table data to next php to process some actions on those values. So how can take those modified table values and how to send it to next php page by ajax or php script. And how can I assign those ajax values to php varriables.Here is the snapshot of table
There are 2 jQuery datatables packages for Laravel (that i know of) which handle this kind of thing for you. No need for HTML in AJAX responses. Im using the one by Chumper and it makes things a lot easier. You just need to provide the data in your controller or route, and add the helper to your view.
https://github.com/Chumper/Datatable
https://github.com/bllim/laravel4-datatables-package << (haven't worked with this one)
I have a question about what backend to use. I have a html page that has various dropdown lists. On Submit I want to sent the results of that page to another page to compile the (average) results. Is there a way to do this without setting up a database? I was thinking of sending the data with Ajax and then compiling the data with Javascript on the receiving page.
I've done something like this before so any suggestions would be appreciated.
You can use jquery to check the changes in the dropdown list. Send the results to a jquery ajax page and get the return value as json. The result json can be shown on the same page with jquery.
I assume the page you are talking about is an html or jsp page. Yes you can use javascript ot process the data and then send it to a servlet and get it back to another jsp.
How do you populate text fields using AJAX from JSP scriptlet with data obtained from Oracle 10g database? How do you get a handle on those input elements of type text from a jsp? Using javascript? but how do you use the values in the scriptlet?
Thanks
Not sure if I understand what you mean.
You have JSP page that reads data from DB and some other page with text inputs. You want to populate these inputs with data from JSP using AJAX call, right ? So just write javascript that will hit JSP page and get a response in JSON format with data from DB and then populate the input fields.
If I am understanding your question right : Why not use a javascript templating engine and just populate and render the template with the json response? If you haven't used templates like this, I would probably investigate. There are quite a few options out there, Mustache is a decent one : http://mustache.github.com/. http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/