Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"/>
<title>Search</title>
<link rel="stylesheet" href="css/default.css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/tablesorter.js"></script>
<script id="data" type="text/javascript" src="js/search.js" xmlData="data/data.xml"></script>
  
</head>



JavaScript
$(document).ready(function(){

	//GLOBAL VAR
	var XMLSource = $('#data').attr('xmlData');
	var keyword = '';
	var catType = '';
	var pub = '';
						   
	var i = 0;

function searchThis() {				
		$.ajax({
			type: "GET",
			url: XMLSource,
			dataType: "xml",
			success: function(xml) { loadPublication (xml) }	
		});
	}


my problem is when i run my html page after simple clicking on html file then it not work but when i run same page using visual studio on local host everything going right.
Posted
Comments
Balasubramanian T 11-Jun-13 5:25am    
problem is in ur button click event... can u post part of this source code
[no name] 11-Jun-13 5:28am    
same click event run on local host dear
[no name] 11-Jun-13 5:35am    
$("#searchButton").click(function() {
keyword = $("input#term").val();
catType = $("#category option:selected").val();

//Reset any message
var errMsg = '';
pub = '';

if ( keyword == '' ) { errMsg += 'Please enter a search term' + '\n'; }
else if ( catType == 'none' ) { errMsg += 'Please select a category' + '\n'; }
else { searchThis(); }

if ( errMsg != '' ) {
pub += '<div class="error">' + '\n';
pub += errMsg;
pub += '</div>' + '\n';
}

//Show error
$('#result').html( pub );

});
[no name] 11-Jun-13 6:01am    
Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. file:///D:/working-website/jquery-search/data/data.xml XMLHttpRequest cannot load file:///D:/working-website/jquery-search/data/data.xml. Origin null is not allowed by Access-Control-Allow-Origin.
this error is showing on chrome bug...
[no name] 11-Jun-13 6:59am    
got my solution C:\Program Files\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files

added it on chrome property because file system not give access to ajax to read file system files. thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900