I have problem when I need to get data from browser console. The data is from map tracking online. And the data in browser console is always update every 10 seconds. What I need to ask is, how we get data in browser console and show it in our php code project. Here is the example : .data in browser console of Mozilla Firefox
The only way you can achieve this is by modifying the console.log function in JavaScript so that you can have a store of the logs in the console (take a look at this question) and then use AJAX to pass it to your PHP script.
Related
This is captured from chrome's developer console
Based from the attached image, is it actually possible to retrieve the data in javascript/Node.js?
I've had already looked into Firefox's documentation for performance.getEntries() and it displays were performance results, none of them captured the containing data/responses .
Doing something like
return performance.getEntries();
or
return performance.getEntriesByType("resource");
will return a json formatted lists, none of them contains the data needed to be extracted.
It seems to me that it is a ajax request, if you can set a hook of all the ajax request, then you can store and retrieve them. You can do this by type code on chrome's console, and the code you may need is here: Add a "hook" to all AJAX requests on a page. Basically it rewrite the XMLHttpRequest.prototype.send method to do what you need.
So, I am creating this website that sets the sessionstorage variable 'logedIn' to true when the user succesfully logs in like this:
sessionStorage.setItem('logedIn', 'true')
That variable is used on the other webpages to see if the user is logged in before showing content, so that users who aren't logged in can't have access to the webpage. It works like a charm, but I have noticed, that if I manually type the code in the google chrome console, I can easily change the sessionvariable. This is obviously not wanted.
My question is: how can I resolve this problem?
PS: the reason why I don't use PHP session variables is because the login procedure is done with javascript. When the login button is pressed, ajax sends the given credentials to a php script, which checks the database. If it is successfull, it sends back a code to the ajax complete function, which sets the variable. If you have a better method of doing what I need to do, you are very welcome ;)
Thanks, Zeno
You can't and it's not safe. After AJAX result you should set cookies and validate them on every page on the server side.
I want to get all the data through the console window of the browser
1) Error messages
2) File name with Line Number.
I tried a lot. Search it but cant find any solution. I tried many Api's but couldn't get any solution.
Error, stack trace, console and many other thing which i have tried but couldn't get the data.
I want to get The data from browser console just JavaScript errors. and want to send it to server through Ajax call.
Is there any way to hide the parameter that I send via post method using the Encoding or any other methods. Because Its roughly show my password in console and If I use Firebug with console Export It send my console log to any server we want show my password can leak through this.
Firebug can't do this, but you can use the console.clear(); after ajax is completed for an empty console.
Also you can use a way to encrypt the password that you sent like md5() function.
As far as I know, Firebug can't do this. However, there is a very useful Firefox extension, in the spirit of Firebug, called Tamper Data. This should be able to do what you want.
No.
It would be up to you to process the output of ConsoleExport when it is received on the target server, to mask sensitive information (passwords and others). (Also it would make sense to connect to that server using SSL.)
A filtering feature in ConsoleExport might be a good idea but there is no such option at present.
Where do I start debugging a jQuery/Javascript function, that calls an API on my server, when it works perfectly well locally - but when uploaded to the server, just returns an HTTP500 error?
I've tried fiddler, but it shows nothing in JSON/XML - the only thing it does show is in the Auth section:
The server Event Logs show nothing around the times I'm trying to test this.
Does the Fiddler response suggest anything is wrong, or can anyone sugget what I may need to turn on in the Event Viewer to capture whatever these 500 errors may be?
Thanks for any help,
Mark
Try adding some console.log() messages which surround the javascript call and are within the callback functions. Doing so will let you know where the failure is occurring. When debugging javascript I typically stick to the Network tab within Chrome Developer Tools and Firebug. By using these tools you get proper output from your console.log() messages.
Specifically, in your jquery result handler I would add the following:
console.log(resultObject);
This will output the entire object tree so that you can drill down into the meat from within Firebug or Chrome Developer Tools... if you need to.
If, for whatever reason, you are opposed to littering your code with log messages then check to see that the call is actually happening when you are testing from your server. You should see whether or not javascript is sending the HTTP request by looking at your network traffic either in Fiddler or browser based tools. If the request is not happening then your code is breaking prior to the call which, in your case, probably means environmental differences.
Is everything referenced and configured properly? Check for null values due to improper configuration or bad references.
500 is a "server error", which basically means something (could be almost anything) broke at the server side.
I would recommend:
Investigate your options for exception handling: http://www.asp.net/web-api/overview/web-api-routing-and-actions/exception-handling
Consider setting the IncludeErrorDetailPolicy to Always, though note that this is a setting that shouldn't be left in-use on a production environment - Error messages returned from Web API method are omitted in non-dev environment
Examine server-side error logging. I'm a big fan of ELMAH. You'll need a little extra effort to get it working properly in Web API - http://blogs.msdn.com/b/webdev/archive/2012/11/16/capturing-unhandled-exceptions-in-asp-net-web-api-s-with-elmah.aspx