JQuery :: Ajax Possible With 'localhost' As Url?
May 1, 2011I was wondering if using ajax-jquery was possible with 'localhost' as url ?
View 1 RepliesI was wondering if using ajax-jquery was possible with 'localhost' as url ?
View 1 RepliesI'm pulling data from a database using a RESTlet server, and using Flot to produce a graph.
My problem is that whenever I make the following AJAX call, I get an "Access to restricted URI denied" error on Firefox. On Internet Explorer I have other problems, but I can tell by my server logs that at least the AJAX call happens, which is more than I can say for Firefox. code...
The url is correct, and the server is hosted on this machine, but Firefox thinks it's trying access another domain. The html file containing this code is located on my hard drive.
How can I get Firefox to allow this AJAX call?
For Ubuntu 10.04, Apache 2, PHP5 and MySQL 5, Firefox 3.6. (I already had Apache, Mysql and Firefox installed, so only added PHP5 via the synaptic manager a couple of days ago).
I have only just started with Ajax and PHP and obtained some demo files from w3schools.com (by googling on 'Ajax PHP database') that I named w3.html and getuser.php. These show how to find person details in a MySQL data base and send them back to be displayed by a browser. They work when Firefox accesses the demo at w3schools.com.
I put these files into directory /var/www on my PC (the upload file directory) and tried via Firefox, but got this error showing in the Firefox Error console:
I also obtained a similar demo from [url]. It failed in the same way, but worked when accessing www.tizag.com directly.
I googled on permutations of 'Ajax', 'XMLHTTPRequest' and 'no element found' and noticed that many have had this problem. A few said that this problem occurs when the Ajax-side expects XML but gets HTML from the server, but did not give any solutions.
PHP works when I put 'localhost/getuser.php?q=2' into the Firefox addressbar. It generates the result table which looks well-formed to me.
I then modified the eventhandler onreadystatechange to
Code:
And found:
i) The status code returned is always 0 (not 200 or any other 3-digit http return code).
ii) The text returned is the content of the getuser.php file, not the content generated by executing the PHP code.
iii) The 'no element found' error is still shown
My intention was to learn and experiment with Ajax and PHP on my local PC, but it did not work. Can it be done, or do I have to get a website and use FTP to upload?
w3.html
Code:
w3.html:
Code:
Use mysql command source w3demo.sql from the MySQL command line.
I have a problem, when I load jquery.js from local, my test server is Apache 2.2.14 and PHP 5.3.1. The code is :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Starterkit</title>
<script language="javascript" src="lib/jquery-1.4.2.min.js"></script>
<script language="javascript">
$(function() {
$("input").click(function(){
alert('Hello World!');
});
});
</script>
</head>
<body>
<lable>pwd : </lable><input type="text" name="text" value="name"/>
</body>
</html>
The browser alert (Missing Objects) in localhost. But if I change src to '[URL]', or double click html and run in the browser, it takes effective. So I think there are some problems in my Apache conf file.
I've got jQuery and 2 plugin libraries running on my website. One runs the navigation and the other runs a dropdown search box. Everything works great on my localhost, but when I copied the directory to the external server none of the jQuery worked. I'm not getting any Errors in my error log, and the directory has been copied exactly. [URL]
View 3 Replies View RelatedI have been searching for days for a solution to this problem and I'm hoping someone here can help.
I have some .html files on my local machine that don't seem to want to recognize .js files
I have XP Pro and IIS 5.1
It works fine in FireFox but not IE7, If I put the javascript in the head of the .html doc it works fine in IE7 but not if I try to access it from an external .js file
If I run it on the internet it works fine so the problem is my local setup
I have even tried setting the mime type in IIS but that didn't work either
I have tried to use the full URL and that didn't work code...
Is it possible to run an HTML file from "localhost" and bypass the
various security checks in place for cross-frame scripting? For
example, on a 2-frame page loaded locally:
a) frame 1 includes a form that accepts the name of a web site
(example: www.foo.com), which a script or perhaps a "target" attribute
then loads into frame 2
b) frame 1 waits for frame 2 to load, then reads (for example)
top.frame2.document.images.length and displays the total in frame 1
I realize that "localhost" is not going to match the domain appearing
in frame 2, but as I myself am running the script, logically, where is
the harm?
I haven't done much testing with this yet, but am planning an
application around this concept and am hoping I can make it work. Any
pointers?
In which ways can I use javascript to detect if the page was coming from localhost.
I know I can search for localhost in string from location.href, but that would miss instances where pages comes from let say:
local.testsite.com or similar
where local.testsite.com are added to the hosts file (windows)
Is there a way to detect this that will allways work?
Any of you smartypants know why my javascript onload function (inside the body tag) is not working (alert pop up box). Using localhost as server and no my pop ups are not blocked
View 2 Replies View RelatedI am doing some development using jQuery $.getJson lately and found the following weird scenario.
1. open google chrome without any argument then load a local html file.
2. the local html file will need to have $.getJson[url] .... bla bla bla and jQuery.support.cors = true.
3. data will get loaded
But if you try to load the exact same json data from other domain or localhost, it wouldn't works.
I don't understand ..
$("#form-dialog-join").dialog() is a valid function which I copied from Jquery demo. What's wrong with it?
btw, all the jquery library is loaded correctly.
jquery provides ajaxStart() and ajaxStop() events. Those two events do not seem to be triggered if the ajax requests are made by Microsoft Ajax tool Kit (from ASP.Net code). Is there any way to bridge those two event models? If not currently possible, is there any future initiative or plan out there to make this happen?
View 2 Replies View Relatedi was using $.ajax method to get my ajax page on my main page,which is working great.But now if i have links in that ajax page then i can't open them in that same div,the links are opening in new window,but i want to open in same part,i tried google it and then found, i have to use iframe instead of div.how to do with only use jquery and div.
View 3 Replies View Relatedi have a series of <select> fields. The first one, via ajax(), generates a 2nd one, based on the first ones' data with the .change() method. there is then a 3rd <select> - who's data will depend on choice of the second one although step 1 works, and i can generate the 2nd one, i still can't generate the 3rd one.
when i test the script on its own, both the 2nd and 3rd <select> fields are fine - but not via the ajax, which leads me to believe that the .change() from the 2nd one, isnt triggering the ajax call - its not being picked up (even the 'hello' alert isnt working).
[Code]...
I am using jquery for getting ajax responses from server side functions.
I am in a situation where I need to make two ajax calls one after another and the second one is dependent on the response of the first one.
I have tried to use a code which is similar to this one?
$.ajax({
type: 'GET',
url: 'myURL',
success: function(data)
[Code]....
Is it possible to get two have two ajax calls , one dependent on the other?
I'm creating an AJAX page that is built using a PHP Class, ie the php looks a bit like this: PHP Code:
$wp_page->addjs('../var/savepolicies.js')
$wp_parser->page = "userpolicywindow.php";
$wp_parser->addlink("Home","../index.php","");
$wp_parser->addlink("Logout","javascript:logout();","");
$wp_parser->getpageid("501");
[Code]...
within this page that has been created, there is an AJAX tree folder which calls another page to be loaded into a DIV by AJAX again. Code:
[Code]...
I don't know why it doesn't work because the page has been loaded with the JS file, but as soon as the link is added afterwards it doesn't work. I take it this is because it doesn't know where to find the JS, but how can I overcome this?
Am calling Webservice in one ajax post, In the success funtion am calling another another method in same webservice through another ajax post method. First ajax post is getting called and returning the string from the webservice method but the inner ajax call is not getting called. I have placed the code here.
[Code]...
I feel like I should be beating a dead horse here, but I've done quite a bit of research and this is not making any sense to me. I'm trying to read an XML document returned in the XHR back from a .load() method. I can't get anything to happen in IE, and it really seems like I'm having to use the WRONG way to get it happening in Firefox and Safari.
Here's some code, the handler passed into the .load() method.
This function traces that the length of the results that are "facility" elements is 0. This is absolutely wrong, as there are 5, and if I set my resultsXML var to the string that is the XML from the response, Firefox will accurately count the elements and report them as 5. However, I understand I'm supposed to pass an XML Document object, NOT a string into the jquery object so that I can parse it correctly in any browser. IE always reports the length as 0 regardless of whether I pass the string or object into the jquery object. But even in IE if I trace the value of the responseText string, the full XML document is seen.
so i have this "class" defined in a javascript file, "a.cross-link". This enables the ability for users to navigate the webpage in a slider format.it works fine if I directly place the required html code:
<a class="cross-link" href="#3" title="Go to Page 2">View Results</a>but if i have php print out that line for me, it doesn't work:
echo "<a class= "cross-link" href="#3" title="Go to Page 3">$name</a>";(Where $name is some variable)
Note: the php code is just your average sql stuff. here is an interesting observation i've made: if i "hardcode" this this into the html:
<a class="cross-link" href="#3" title="Go to Page 3">View Results</a>
and then i go to generate the sourcecode, this is what appears (this works): <A class=cross-link title="Go to Page 3" href="#3" jQuery1283131847233="30">View Results</A>
but if i have the html made by a php echo statement, it just stays the same - i dont get a jQuery1283131847233="30" generated in the sourcecode.i'm new to jquery and ajax stuff. to me, it seems like the "cross-link" class i have defined in the javascript isn't being applied to correctly.can you invoke javascript from a php echo statement that is formatted to produce html code? here is another thing i believe is true: when the page loads, the javascript loads. the users, through the use of ajax, submitts a sql querey and navigates, using a jquery slider, to another div (where i want the user to go after selecting a resulting link from the sql query). so the javascript is going to execute before the list of results is produced. do I need to rerun the javascript each time new php produced sql data is populated in a div? if so, how?
This is something new I have been trying to do because the site I'm doing development for does not support ASP and I find it easier to populate PDF forms in ASP rather then PHP. So what I have done is on my Church's website I have the form that needs to be filled out developed as an HTML form with some PHP serverside code. I am then using jquery ajax to send the form values to the other URL (My own personal webserver where I set up a subdomain) where the values will be dumped in to the corissponding form fields in the pdf template and then emailed to the secratery at my Church.
Here is my problem, $.Ajax can not send to a URL outside of the server it is being run on. Now I have read on various forums that 2 ways around this are to either have a proxy page or by using jsonp. I looked at both options and am still unsure how to handle this. jsonp seems like I would have to rewrite my ASP page to be able to read jsonp values and I really don't know where to begin in my ASP page to get the jsonp method to work. What I found with proxy page also seemed to be problematic because the samples I found did not pass variables to the other page.
I just want a really simple (or well explained step by step) process that will allow JQuery to take the form values filled out on the PHP page of my Church's website and pass them to the ASP .NET/C# page found on my personal server and then take the results (either successful or failed) and return it to the php page to display an appropriate message. Right now I'm using String txtFamilyName = Request.Params["txtFamilyName"]; in my asp c# page to grab the values from Jquery and put them in a variable.
I have the following function:
Code:
Then I have in showresults.php lines
Code:
Everything is fine, but I don't know how I can use this with GET. I tried to replace type: "POST", with type: "GET", and then if(!empty($_GET[clickedPage])){... but it doesn't work.
What would be the correct syntax in function to get in showresults.php data with GET?
jQuery.ajax({
url: "/sharedImage",
type: 'POST',
data : fileName,
async: false,
dataType: 'html'
})
Here i am posting the request to a servlet.The call is going to the servlet.But i am not able to get the data (filename which i am sending ) in my servlet. How to access the param value in the servlet.
I am wanting to make an ajax call across domains. Im attempting to call an external api with json data and (hopefully) receive a response. It's a mapquest api to obtain driving routes.Is there a mechanism in jQuery that will allow me to make a cross-domain ajax call?
View 12 Replies View RelatedI have a little issue with the use of jQuery and a call with the method Ajax. The problem appears with IE7 when I call just after the page was loaded. If I wait 2/3secondes, I don't have this beautiful message :
[Code]...
The $.ajax call was working fine in 1.4.4. However, upon upgrading to jQuery 1.5, all my AJAX calls are triggering the error callback instead of success. Furthermore, the error being thrown is empty (or at least isn't showing up in the alert box. This happens on IE, Firefox, and Chrome.Getting the same problem with $.getJSON as well (which makes sense if its just a shorthand $.ajax). I've included the function that makes the ajax call below.
[Code]...
i want to send a simple HTTP-Request to a JavaEE Backend with jQuery. In Chrome/Firefox it works just fine. In IE on the other hand, it does not. IE does not show any error in the console, nor does it show the request in the network tab. Nor does the request receive the backend. So, am i doing someting wrong here?
[Code]...