How can I check authentication in ajax url?


Consider the following ajax call:

function drawCharts() { var jsonData1 = $.ajax({ url: "http://localhost:****/*/*", dataType:"json", async: false }).responseText;

My index.html

<div id="chart_div" title='Speedo Information'></div>

I am making an api that converts json data to tabular form using Google Visualization Api.

While accessing the url alone the url asks for a user name and password. I have the credentials.

<strong>NOTE:</strong> The username and password is used to protect the data in the url from unauthorized access.

I need to ask for a user name while opening the index.html page and then display the table.


jQuery has an Ajax interface pretty well described here:

<a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a>

There basic example looks like this with your URL in there. It shows how to override the MIME type and how to get a function called once the request returns data from the server. The API also offers an error function and many other features to transform the request in various ways.

$.ajax({ url: "http://localhost:*/*/*", beforeSend: function( xhr ) { xhr.overrideMimeType( "text/plain; charset=x-user-defined" ); } }) .done(function( data ) { if ( console && console.log ) { console.log( "Sample of data:", data.slice( 0, 100 ) ); } });

If you want to send the login and password or any other data to the server, you may also use the data: ... field. That can hold data as in a POST from a form.


  • vim tabular plugin question
  • How to associate multiple value to a property using cypher queries in Neo4j
  • jQuery .load() but exclude script tags
  • Force html table to have eight columns on a single row
  • Sorting Tabulated Data
  • UIImageJPEGRepresentation giving 2x images on retina display
  • Gradle - How to detect --debug flag from command line?
  • how to sort an arraylist that contains string arrays?
  • HTTP Module intercept requests and breaks custom errors configuration
  • How to bind comma separated list of values to List
  • Excel Date field value differs from c# dateTime by 1 day while reading excel file with EEPlus
  • Tinymce strips attributes on submit
  • Create a multiple screen android application
  • Streaming screenshots over WebRTC as a video stream from iOS
  • jQuery: add elements until a particular height is reached
  • uml Composition relationships to RDF and OWL
  • Row to Column conversion in Talend
  • Azure table store snapshot/backup capability
  • xtable package: Skipping some rows in the output
  • Seeking advice on Jetty HttpClient Hang
  • Change JButton Shape while respecting Look And Feel
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • jQuery tmpl and DataLink beta
  • Web-crawler for facebook in python
  • Google cloud sdk not working when python points python3
  • RestKit - RKRequestDelegate does not exist
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Revoking OAuth Access Token Results in 404 Not Found
  • SQL merge duplicate rows and join values that are different
  • Proper way to use connect-multiparty with express.js?
  • using HTMLImports.whenReady not working in chrome
  • How to set the response of a form post action to a iframe source?
  • embed rChart in Markdown
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Android Heatmap on canvas or ImageView
  • Conditional In-Line CSS for IE and Others?