jQuery ajax call only from HTML page

ps0604

Given the following jQuery code that makes an ajax call:

$.ajax({
  url: "test.html",
  context: document.body
}).done(function() {
  $( this ).addClass( "done" );
});

The problem I have is that the user could manually enter test.html on the URL and see the response on the screen. How to avoid that?

Ajay Chaudhary

One way you an do this to create a variable for in some other script or location so the user will only see the variable name.

Also send you request through post method and make you server ajax reponse page respond to POST request only( say using some server side language like PHP, ASP.Net or JSP). This way even if the user find out the path of the url it will not be able to view its contents.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to render HTML with jQuery from an AJAX call

From Dev

Ajax Call using Jquery in HTML and take a response to other Html Page

From Dev

Jquery ajax call works only on first page load

From Dev

call ASP page method from html page using jquery

From Dev

How to call a jquery method from PHP page loaded through ajax

From Dev

If error from jquery ajax call should be redirected to other jsp page

From Dev

If error from jquery ajax call should be redirected to other jsp page

From Dev

jquery ajax call reload page

From Dev

HTML returned from jQuery AJAX call acting weird

From Dev

JQuery: extract content from ajax-read html page

From Dev

Page get refresh on ajax call response only on first time in mvc through jquery

From Dev

Ajax call not working from jquery

From Dev

Unable to call Page Method using jQuery ajax

From Dev

Why page reloads after JQuery ajax call?

From Dev

Jquery Ajax call in wordpress plugin page not working

From Dev

Unable to call Page Method using jQuery ajax

From Dev

Wordpress ajax call returns entire html page

From Dev

jquery Ajax call seems to work only once?

From Dev

Jquery Ajax call doesn't hit the action method/returns entire HTML page

From Dev

jQUery ajax call to asp.net webforms returns html page instead of calling the specified method in the url

From Dev

Jquery Ajax call doesn't hit the action method/returns entire HTML page

From Dev

jQuery:Parsing an ajax HTML page result with jQuery

From Dev

Make ajax call from gsp page in grails

From Dev

Forcing AJAX call to be HTTPS from HTTPS Page

From Dev

Call function from Ajax reloaded page

From Dev

Make ajax call from gsp page in grails

From Dev

Making ajax call on navigating away from page

From Dev

posting the respinse from an ajax call to another page

From Dev

CakePHP returning HTML from remote site page to view through AJAX call

Related Related

  1. 1

    How to render HTML with jQuery from an AJAX call

  2. 2

    Ajax Call using Jquery in HTML and take a response to other Html Page

  3. 3

    Jquery ajax call works only on first page load

  4. 4

    call ASP page method from html page using jquery

  5. 5

    How to call a jquery method from PHP page loaded through ajax

  6. 6

    If error from jquery ajax call should be redirected to other jsp page

  7. 7

    If error from jquery ajax call should be redirected to other jsp page

  8. 8

    jquery ajax call reload page

  9. 9

    HTML returned from jQuery AJAX call acting weird

  10. 10

    JQuery: extract content from ajax-read html page

  11. 11

    Page get refresh on ajax call response only on first time in mvc through jquery

  12. 12

    Ajax call not working from jquery

  13. 13

    Unable to call Page Method using jQuery ajax

  14. 14

    Why page reloads after JQuery ajax call?

  15. 15

    Jquery Ajax call in wordpress plugin page not working

  16. 16

    Unable to call Page Method using jQuery ajax

  17. 17

    Wordpress ajax call returns entire html page

  18. 18

    jquery Ajax call seems to work only once?

  19. 19

    Jquery Ajax call doesn't hit the action method/returns entire HTML page

  20. 20

    jQUery ajax call to asp.net webforms returns html page instead of calling the specified method in the url

  21. 21

    Jquery Ajax call doesn't hit the action method/returns entire HTML page

  22. 22

    jQuery:Parsing an ajax HTML page result with jQuery

  23. 23

    Make ajax call from gsp page in grails

  24. 24

    Forcing AJAX call to be HTTPS from HTTPS Page

  25. 25

    Call function from Ajax reloaded page

  26. 26

    Make ajax call from gsp page in grails

  27. 27

    Making ajax call on navigating away from page

  28. 28

    posting the respinse from an ajax call to another page

  29. 29

    CakePHP returning HTML from remote site page to view through AJAX call

HotTag

Archive