logo

NJP

6# Create a UI script to call the script include and alert the result with UI page

Import · Nov 23, 2019 · video

welcome back everyone so in this video what we are going to do is to write a client script the clients tape is going to make a call is going to call a server-side script okay in our case is going to call the script include that we have wrote last time so let's get started let's create first our UI script so I'm going to click on create application file look for you I scraped so you can find it here we are scrape and it should have client development and click on create let me just save this page and here I'm gonna give here title of my now I'm going to just delete everything we have here and let's get started to write our code so I'm not create a variable called equal to glide Ajax so this is a specific class which we can use now to make a call of a client script we do not mention here what is the script you are going to use we are going to use the script includes so I'm gonna just keep the name of the script includes following one not the API name just one so I'm gonna take that one right here and then as we're giving this information we are also have to give some other information which is the parameters so the first parameter that we are going to say is okay this is a script so that you should use but what are the what is the function what is the method addition that I should use there because skipping period can have multiple methods multiple function in there we do have only one okay having a problem two loads I'm gonna just do it once more and you can see here we have get weather info that's the only one we have for now so I'm gonna specify that information so I'm going to add parameters okay before even that I should spit I should write the following syntax into sis the school name it should be exactly this one not something else sis form and this code name and then you put the function the next parameter is going to be because as you know we have here but before the value Chennai for the location so instead of having two now I'm gonna have something else and and I will have Chennai in already ice cream okay we're gonna have the input value in our client script and then we're gonna leave we're gonna just erase that part like we are not going to have the the value of the city in our server side script okay so we'll just create that parameters so this undisclosed location the location here which is going to be lets me the same street okay the fact that I have wrote this line here is going to help me to replace Chennai by the following syntax this get parameter I'm going to specify which parameter system location the factory that we have this line now in here we will be able to push the input here let's say the parameter is value Chennai to our script info in this way okay so so now we have set the let's say we have given what is the script include dry area export is a function you should use what is the input value in parameters they are gonna have this kind of information we have to get the result right in order to get the result we're gonna use what we call get X and now get examiner will allow us to send these information to execute the method and the server side and get the result back and we get the result back by using a callback function I'm gonna call the callback function attacks response okay and I have to therefore write the function create a function inside my function for now is going to be empty depends what we're gonna have output so we are receiving the response with the XML format so we have to for when we are going to output everything from the server side we're gonna create some XML tag here so we will receive the same kind of information here so I'm gonna transform the output and we have here like we're gonna modify the code here for example here we have our city and then uploaded city so we have the same thing for the rest of the variables you have created so I'm going to just modify this one I'm going to create your city even though the existing want and I'm gonna this new item okay this one says I'm created creating an XML tag called see ok this is the first thing and the second thing I'm gonna set some attributes to the XML tag so city so I'm going to create another variable called place equal to CB dot so this 1 this variable dot set attribute and what attribute we're gonna create is valuing call it value so you will have to imagine a city tag inside we have an attribute called value which will be equal to the value that we are getting from the action so that's the thing that I'm going to put right here so just bring this line right here okay let's say I'm gonna keep it like this and then this is the series already defined so I'm gonna erase this time because I don't need because now we do have the city variable here we have the tag created and then we have another variable that we are getting let's say yeah we are setting the attribute okay we are setting the attribute value and we are putting inside that bag inside that value the output that we are getting from the action just the fact that we have written these two lines here we can write kind of the opposite they're not get that we are setting the attribute in XML form in XML tag called city we're gonna get the attribute from the XML tag city on the other side in here so let me just come on this line and then save this one and then we're gonna bright here or I'm gonna create here bar C so this is a poor city this is a local variable that I'm using here okay it is it is not the city that we have here okay it's totally different so it's going to be equal to [Music] let's say server responds okay all right so this is the one I'm very again the result so response response XML get elements by tag name ok so inside I'm gonna give what is the tag name that we are having you're having the tag name city if you remember this is a tag that we are creating right this is the time that we are creating so that's the one that you should use now what we are going to do is get the value from the tag ok so we have the tag city and we have an attribute value which will be equal to something so I'm gonna get this in a variable called place I guess I don't need this like this okay we can do like this you don't need to create a typo it's mine it's not useful freaking you can keep it like simple like this varsity in this new item City and then city said that tribute and so on and now here we're gonna create a variable called place which will be accessing City the following on which has now the result from this type this is a syntax that we have to write so 0 and then you're gonna get the attribute right get the attribute the attribute name is value inside we have the city right now theoretically we have the city in the variable place I'm gonna make just another to make sure that we are having to see in here so it's going we're gonna have a pop up and we should have the city of Chennai like Chennai International or something this is the result that we have we had before so I'm gonna save I'm gonna submit so I guess everything is proper here let me check one more time okay it's good so right so we have now this time here we have our we are scraped and what we are going to do we're gonna create we are going to create because IV we have another we are going to create an AI page from where we're gonna load the script okay I'm gonna just create a UI page we hear click on create' give it a name for example whether bi page like this okay we're gonna have an endpoint gonna use this endpoint to view our results I'm gonna keep it general and inside our chili tag don't write the following script script source equal to I'm gonna copy the API name of my UI script just paste it here dot J okay this is the one that we should write and let's close our script tag so this is going to allow us when we are going to launch this page is going to exactly load the following script which is here okay so this one is going to make a call to the client server side script our scripting truth which is here and this one is going to actually get the Chennai as location execute the action get the output work on the format with the XML and we're gonna get the result in here and we're gonna work again on the XML format to get the value store it in the place and then make another this is a whole operation going on here so let me just save this one okay we have something wrong here script what's going on here open code is okay great so let's try to load our page and see if we are going to get if you are going to get something out so I'm not logged in this is a message I would get so I'm gonna put mine I mean I should have a pop up okay as you can see here I have Chennai International India so it's good we have done successfully I mean we have pushed the value from the server side to the client side and now what we need to do is just to modify for rest of the variables that we have here exactly the same thing same operation and we are going to do exactly the same operation in our Ajax response curve shape function thanks for watching that's the video that we are going to do for them

View original source

https://www.youtube.com/watch?v=Rjxjm6SzbXA