Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide details in jquery ajax from browser page source

I am using jquery for all my ajax thing, I don't know if that is fine but I use that for now.
I have one text input when user type characters in it I call server side get some values and add them on the view.
Code that I use bellow works fine but I want to improve it a little.
How can I make this ajax call so that users that want to investigate my page source code can't see what I call here?
So basically I want to hide from page source what url, what type and data send I use here, is it possible?

$(function () {
        $("#txtSearch").keyup(function (evt) {        
            $.ajax({
                url: "/Prethors/Users/SearchUsers",
                type: "POST",
                data: "text=" + this.value,
                success: function (result) {
                    $("#searchResult").prepend("<p>" + result + "</p>");      
                }
            });
        });
    });
like image 871
1110 Avatar asked Dec 08 '11 21:12

1110


People also ask

How to hide AJAX code?

You can't hide the code. You can move it to a separate js file, but still a user will be able to see it. A solution would be to obfuscate it. See this question.

Which method is used to hide selected elements in jQuery?

The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none.

What is AJAX how it is used with and without jQuery?

What About jQuery and AJAX? jQuery provides several methods for AJAX functionality. With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page!

What is form data in AJAX?

It is a method to provide form values like text, numbers, images, and files and upload them on the URL server. It is a function to create a new object and send multiple files using this object.


1 Answers

No, a user will always be able to figure out what calls you are making if you include it in javascript.

You can compress and minify the javascript, but a determined person will always be able to find your url calls.

Here's a js compression site, for example. http://jscompress.com/

like image 144
Michael Dillon Avatar answered Sep 20 '22 10:09

Michael Dillon