I have a button that is used for displaying an annual leave request by doing an ajax call to a servlet which then retrieves data in the response and displays it on the modal.
'view modal' buttons in a table.
Once one of these buttons are clicked, they run a javascript function which does an ajax call and displays the data that recieved on the modal
(Screenshot). Basically I need another ajax call to a servlet as and when the "respond to request" panel is clicked. I've heard of event binding which might be useful for solving my issue, however being the newbie I am, I haven't seen an example of how this works that I understand so maybe someone could attempt to provide one here for me.
The second ajax call is to basically running a query against the database to check whether or not the currently logged in user on my web app has already accepted/declined the request so that I can disable/remove the buttons without refreshing the page.
Thanks in advance!
Two options for submitting different calls:
Each button submit different form, each form submit different action - example with jquery
Each button submit different JavaScript function the execute different ajax call
- example JavaScript
Related
We work on a 3rd party opensource CMS. We cannot edit any piece of code of it in any sense.
There're forms to fill which we design for the users. Those forms have section tabs. Those section tabs are implemented with a plugin.
Instead of loading all form tabs content on page load, it basically loads dynamically via AJAX when tabs are clicked. Classic.
I created a button on a "CUSTOM HTML pill" on the form (which lets you inject HTML+JS+CSS), which on click basically triggers a click on every TAB on the designed form. This way, it loads everything on page (when loaded, just hidden from that moment on, and not ajax is called again for that specific clicked tab).
Then I serialize all the form and send it to a Python Flask server via an AJAX call made by me.
THE PROBLEM:
As I said, before ajax call to Flask, I trigger click to every tab to load on page all form fields there, because this way I sent ALL the real form to Flask, if not, only some form pieces goes to the request.
If every goes fine, it goes as expected. But tab content ajax load is ASYNC, so sometimes it doesn't finish and Flask receives incomplete form.
THE QUESTION:
On my custom button click, how can I force clicking to every tab, and wait for ALL the async requests made (programmed on the 3rd party plugin not editable) to finish and finally, make my call to Flask with the complete Form serialized data?
Cannot use promises (await, $.when()) because tab click makes a common $.ajax() call but not with a return $.ajax().
//Pseudocode:
mybutton.click(
$(allTabs).click() //this creates a cascade of ajax calls loading every tab data from server. Just once (first time)
WHEN ALL PREVIOUS ASYNC CALLS FINISHED AND ONLY THOSE:
let FORMDATA = serialize(FULL FORM WITH EVERY TAB LOADED)
$.ajax(post call to my Python Flask, FORMDATA)
)
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'm programatically creating a Google Form using Google App Scripts right now, and my script automatically generates a page for each of the respondants that the form will be emailed out to.
Currently, the form has a dropdown at the beginning that the person uses to select their page, and then it forwards them to it, however, I'd prefer it if the email already sent out a pre-responded form that already started them on their page.
The reason I'm throwing them all into a single form is because I'm using Triggers to detect the form's submission, and since I have more than 20 people that require a form, that would break the trigger limit.
EDIT:
Example code:
the Form.getPublishedUrl() function returns the URL to respond the form, starting on the first page, however, I would like a URL to respond to the form starting on the 3rd or 4th page.
While the FormResponse.toPrefilledUrl() will allow me to autofill the correct response on the first page, it will not allow me to start the responder on the page that he would be forwarded to based on his pre-filled response on the first page.
tldr; :
How do I get a link to a specific page on a Google Form using Google App Scripts?
This should be a comment but don't have 50 rep yet...
Why do you need various HTML pages?
I think you should refactor your code so every form is on the same HTML and everything shows and hides with Jquery or Javascript. You can send the same URL but with differente URL parameters.
If this isn't your case, you should post some code of yours and detail a little bit more your question. Also, wich limit does it triggers?
I have several forms on a site. Each one has a 'save'button. When clicked, it does some AJAX to save the data on the server. I'd like to have the button become disabled once the server returns success. I'm not quite sure how to go about it since there will be multiple save buttons. Do I just need to pass some kind of identifier for each button to the server so it can return it?
Thanks!
I am using html5, javascript and JSP for my project. I want to know if there is some method that i can used to execute a query from my servlet without actually posting back the page. i know it can be done in ASP.net but i do n't how it can be be done in java script and JSP. Actually i have a dynamic webpage displaying data from server.what i want is that in a click event of button i want to execute a query form server and update it on the page. i know i can submit the form but it will submit the page which i want to avoid.Any suggestion......
regards
nquazi
You can use an AJAX request to submit inputs and get back an output without reloading that page. Here is a previous stackoverflow answer that shows you how to do a HTTP GET request.
HTTP GET request in JavaScript?
You will then need to process your inputs, run the query, and send back an output on the backend server.