How can I run ajax code without web server?
I m able to run the ajax without webserver the problem was with my code the code written below that i had run on my filesystem u can use that as well.
function do_the_click(brl)
{
alert('inside this method do_the_click');
alert(brl);
var request = $.ajax({
async: false,
url: brl,
contentType: "text/html",
type : "GET",
dataType : "html",
});
request.done(function( msg ) {
alert(msg);
$( "#contentarea" ).load( msg, function() {
alert( "Load was performed." );
});
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
}
Java Collections
Loading local files with Javascript without a web server
If you insist on using Chrome, it have some command line flags to allow access to/from local originated files (--allow-file-access-from-files
/ --disable-web-security
). Do note that you need to run entire browser from scratch with those flags - i.e. if there's already any other Chrome windows open flags WON'T have any effect and that effect persists across ALL windows until Chrome is closed, which is, obviously huge hole in security.
You can set up a lightweight local server if you pack your "application" with some kind of automated setup script. This is still not very good, because you'd need to install executable that user might not want or even be completely unable to install due to restrictions.
You can pack your HTML/JS-based app as Chrome extension - extensions have much wider permissions than random code, but then you'd need to either distribute it through Google Play or provide instructions to manually install extensions for your users.
And finally, you can format all the data, including your configuration and text files your mentioned as valid JavaScript code - i.e. pack a story1.txt
to story1.js
like:
var myapp.story1 = "Complete text of story1.txt"
and then just dynamically select stuff you need from corresponding vars or even use DOM manipulation to only load scripts you need through dynamically adding <script>
tags. In my opinion that would be best option because it is less intrusive: it doesn't requires any installation/reconfiguration, it just works out-of-box.
Related Topics
How Would I Implement a Simple Site Search with PHP and MySQL
Push Notifications from Server to User with PHP/Javascript
How to Create a Facade Class with Laravel
Zf2 - Get Controller Name into Layout/Views
Undefined Index While Uploading File
Laravel Model Callbacks After Save, Before Save, etc
PHP Get Dropdown Value and Text
How to Determine a File's True Extension/Type Programmatically
PHP Multiple Ternary Operator Not Working as Expected
Inserting Line Breaks into PDF
Get the Hierarchy of a Directory with PHP
Foreach Value from Post from Form
Original Variable Name Passed to Function