calling a java script function on another page using php - javascript

i am working on google map api.
i've created a function named as codeAddress which shows the map of state/city given by user in a text field named on a click event (button name show map). I want to show the map on another page on a click of same button. please help me how can i call the codeAddress function on another page?

You are trying to implement Client-Client protocol. Unfortunately, you'll need third part in this system^ server. There is several options:
Long polling from the second page to server-side Stack. Stack is abstract storage with function name and arguments. First page puts function to the stack (simple AJAX request) and maximum after a polling lag the second page will receive this Stack item.
Use server as connector and make peer-to-peer connection. After this you'll be able to send messages to the opened pipe.
Use something like socket.io - Pub-Sub pattern realization written in Javascript (Node.js)
All these options are not trivial and requires some additional work.

Related

Chrome Network Inspector: Is it possible to find the calls for a specific DOM element?

I have a table that gets filled with data received from an API call. Is it possible to somehow "lock" Chrome's network inspector on this element (= the table) and make it only show calls related to it and not every single one made by the rest of the page? Maybe this is doable with an extension?
I would say it's not possible to achieve, because:
The view and the logic are also seperated in (modern) frontend applications. So the app can request a JSON file from a server when it starts, and then passes those informations through the entire application (tables etc.)
A table itself is not calling the endpoint, and can be just generated by a function with the prefilled data.
The closest you can get is:
Record screenshots in Chrome to see when the table gets filled. There you see which calls got made during this period of time:
Afterwar you know what's the "name" of the call, you can put it in the filter/search field and reload the page. Afterwards, you will always just get shown the call you selected and is possibly responsible for filling the table.
Of course, you can also go by hand and say:
What is inside the table? Which information does it display?
Then go through the api calls and look for the information in the response bodies
Once you identified the call, filter it inside the chrome dev tools.
And if you want to go to the next level:
Copy the call als a cUrl (via right-click on the call) and insert it in Postman and also install Postman Inceptor. Afterwards you can pass website calls (the one for your table) to Postman so you can have a closer look at it and also re-call it every time you need the specific call.
To summarise:
Figure out which call has the information for your table, extract the call using Postman Inceptor and pass it to Postman with it. Then, you can analyse or do whatever you want with it.

How can my ASP.NET page go back and forth from client to server code and back several times?

OK, the tite seems a little confusing, so I'll try to explain more thoroughly...
The process the page does currently follows the following sequence:
- User clicks a button
- server-side code goes retrieve data from the DB and exposes said data to the client using, populating, let's say, hidden fields.
- client-side code uses this data to fire up a an ActiveX component which performs a few tasks with the data provided.
And this works fine, however, we need to optimize the process because the ActiveX component is not fit to handle high volumes of data. We need to send data into "blocks" to the component, rather them send all data at once as it is done today.
However, I just hit a roadblock here, on how can I make the page go back and forth from server to client code multiple times? Like... "user clicks a button, server retrieves first block of data, sends to client, client executes ActiveX for the first block, client requests next block, server retrieves second block, sends to client, client executes ActiveX for the second block, client requests third block... and so on"? I can't get past the first request, since I can't register a client script block 2 times and expect AJAX to handle those multiple sequential callbacks...
Or is there a way?
This sounds more like an architectural issue than anything else.
What you should be doing here is:
1) User clicks a button. This is NOT a regular submit button. Just a plain old button that executes some local javascript.
2) Local javascript makes an AJAX request to determine how many records are available.
3) That javascript then does a loop based on the number of available records divided by the amount you want to pull per chunk.
3.a) Execute AJAX request for a chunk
3.b) Throw the data into your ActiveX control - which, btw, I really would suggest you guys think about getting rid of. There are so many issues with ActiveX that it's not even funny.
4) Repeat 3.a and 3.b until completion.
You'll notice that at no point was a full post back performed. You'll also notice that you shouldn't have to register any client script blocks.
Now the draw back here is purely in the ActiveX control. Can it be instantiated from javascript multiple times in a page or are you forced to only use a single instance?
If it's limited to a single instance, then you'll need a different approach entirely.

CouchDB run a list function on _changes

I need to create a feed based on changed documents. I figured the _changes api would be perfect in this case. Ie simply store the last sequence id client side, so we can use it to limit the results in the next call to _changes.
Currently, the application performs the following:
calls _changes with since/filter parameters
calls a show function for each id in the _changes feed
renders all changes into the customer feed
What I would like, is to be able to call a list function on the entire _changes result in a single request. This would remove the need to explicitly parse the _changes result on the client, and move that functionality to the server.
The question: is this even remotely possible?
I have been trying to implement a view, doing "almost" the same thing as _changes, but without any real luck.
This is not possible at the time, and the _changes API is different enough from regular views that it's not entirely straightforward to implement.
There is a ticket open in the CouchDB issue tracker, but it hasn't been updated in quite a while.

Javascript, .NET : show and consume an OK/Cancel alert

Here is my situation:
I am building a schedule asp.net app and i want to alert the user to the possibility of time collisions (if the user is inserting a new schedule for someone and that someone has something already scheduled for that time).
I have read and found lots of "calling JavaScript inside ASP.NET" articles here and out but they all are either showing how to call a function as soon as the user clicks something,
as soon as the page loads or just showing a general alert window with just the OK button.
My question is then, how can i call a javascript messagebox with ok and cancel buttons from the middle of a function /handler in c# and have access to whatever represents those buttons so i can branch accordingly? I hear jquery messageboxes are prettier than the regular ones, how would i proceed using those instead?
My question is then, how can i call a javascript messagebox with ok
and cancel buttons from the middle of a function /handler in c# and
have access to whatever represents those buttons so i can branch
accordingly? I hear jquery messageboxes are prettier than the regular
ones, how would i proceed using those instead?
This isn't really possible. Javascript happens on the client. c# function handlers happen on the server. They happen one after the other server > client > server > client, etc. You can't break out in the middle of server side code and go back to the client, and then come back to the server.
Everything that happens up to the point the form is posted happens on the client (unless there is Ajax involved), once the form is posted and you are in your c# code, everything is on the server, until the page life cycle completes and the response is returned to the client.
If you want to have a javascript confirmation function, it needs to happen BEFORE the form is posted to the server, and you need to store that result in a form field and pass it. Alternately, you can choose not to post the form at all based on the user's choice of OK or Cancel.

passing parameters from js to .aspx page using windows location

I can pass parameters from javascript function to an aspx file. I use windows.location.href for that.
When the execution gets to the aspx page, it runs and it tries to call multiple WCF services using those parameters. But the moment it calls the first one, the IE window on the back takes me to the root view that lists all available aspx pages.
i've tried setting a breakpoint on the page load that is receiving those parametrs. I try to step through the codes, it will let me do that just fine but when it calls the first WCF service, it will do the above to the IE window BUT it will still let me continue steppng through the code after that.
IE window should be waiting for me until I am done executing code on the server, right?
It has something to do with the combination of WCF calls & JS window.location.href statemetn. I know that for sure. It consistently is doing that at a specific line of code (the first WCF call).
I don't see this behavior if for instance, I try to pass the parameters in a session variable coming from another .aspx page.
Has anyone seen this behavior? do you know what is going on?
Thanks
--- REPHRASED---
thank you for the feedback.
hari, I am doing this from my local machine running VS 2008. I do use forms authentication.
Maybe you didn't get my questions, because I didn't phrase it properly like Diodeus thinks, so let me try again:
I collect input values form one page using JS. Then I need to pass these parameters to an aspx page using windows.location.href.
I set up a breaking point at the page load event to make sure that execution is reachign the aspx page. and it does.
This page successfully receives those variables and does more processing like calling external WCF services. At this point the IE window is locked and becomes unviewable because the execution is still taking place. This is normal (is this part that throw you off?).
The moment I start executing a call to the WCF service, the IE window finishes loading and it takes me to the direct browsing WHILE I am still debugging inside visual studio (like a line of code beomes highlighted in yellow). I can continue stepping throw using F10 or F11, but my IE window on the back is done!? It should continue waiting for me until all lines of codes finish processing.
I hope this helps. Pls let me know if it does and be able to help me figure it out.
Disable directory browsing for that website (at IIS), and set a default page for the website (also at IIS).

Categories

Resources