what's weird about my error is that it ONLY occurs in the firefox extension I have linked to at the bottom of this post. I cannot reproduce this error in any other setting.
I have this ajax request
$.ajax({
type: "GET",
dataType: "jsonp",
url: url,
jsonpCallback: "JSONCallback",
data: {title:$("#txtTitle").val(), url:taburl},
success: function(data, textStatus) {
if(data.code > 0)
{
$("#icon").removeClass().addClass('accept');
}
else
{
$("#icon").removeClass().addClass('error');
if(data.code == '-1')
alert('kunne ikke finde din ønskeseddel på e-ønsker.dk - besøg e-ønsker.dk, og prøv derefter igen');
}
},
error: function(xhr, textStatus, errorThrown) {
alert("XMLHttpRequest="+xhr.responseText+"\ntextStatus="+textStatus+"\nerrorThrown="+errorThrown);
$("#icon").removeClass().addClass('error');
}
});
server returns
JSONCallback({"code":405});
headers are application/json
so why am I getting a parseError saying JSONCallback was not called? I thought jQuery was supposed to handle that for me?
the code is from http://builder.addons.mozilla.org/addon/1022928/latest and the file in question is data/panel.js
The problem is with window. The easiest way to fix this will be to edit the jQuery code (I know, I hate doing this too) to use unsafeWindow rather than window.
have you tried to enable the"Cross-Origin Resource Sharing"
using :
jQuery.support.cors = true;
i had the same issue with firefox a while ago and using that line before making my ajax call fixed it for me.
i coulnd get your fizzle to work for some reason :) good luck
This isn't really an answer, but why are you using jsonp? Code running in the context of a Firefox extension isn't subject to the cross origin restriction.
My understanding of jsonp is that a script tag is added to the document using the server's response so that your callback is executed. In a Firefox extension "document" is the XUL UI not the regular page's document. I'm not sure that adding a script element to XUL will cause the browser to execute that script.
Hope this helps!
Related
alert("orger");
$.ajax({
type: "GET",
url: "localhost:8080/greeting",
success: function(data) {
alert("hello");
}
});
The browser outputs "orger", but not "hello". What is the issue? When I invoke the url in the browser, the page renders successfully.
The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. , use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.
too many possibilities for Ajax not returning.
- It might be jQuery not plugged
- url not found.
- HttpService got error, so it goes in error part.
- etc.
so look at the below link, i will help you.
enter link description here
I'm trying to grab some data from the database on a page in typo3 using Ajax . So after a long time looking for the appropriate way to do it , I got convinced that The Ajax Dispatcher is the best tool to do the job . So I created the file following the instructions to be found here.
Now when I make an Ajax call on my page , the console displays a 500 (Internal Server Error).
joined is a snapshot of my console tab.
and this is the jquery function that gets run on an onchange event .
function getContent(id)
{
console.log("Start process ...");
$.ajax({
async: 'true',
url: 'index.php',
type: 'POST',
data: {
eID: "ajaxDispatcher",
request: {
pluginName: 'listapp',
controller: 'Pays',
action: 'getMyCos',
arguments: {
'id': id,
}
}
},
dataType: "json",
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
}
});
}
Could someone please help me , I just started developing with this CMS of shit :p
If you indeed followed the tutorial step by step, and you use TYPO3 V6.2, you would get errors cause of depricated function calls to t3lib_div (as the title of the blog item says, it is for version 4.x)
Always keep your error.log open, it's your best friend in times of coding stress
You can also use typenum for ajax calls
http://lbrmedia.net/codebase/Eintrag/extbase-60-ajax-bootstrap/
I can imagine that starting with TYPO3 can be frustrating, but calling it a 'CMS of shit' does not seems to be a smart strategic move if you need help from people who think differently about it.
I develop phonegap app for symbian (cordova for symbian I'm get from here)
After 3-5 seconds when my app begin execute ajax request, I get error:
Maybe someone faced with this issue?
Update1:
I make cross-domain ajax request with jquery mobile 1.8.1
$.ajax({
type: 'GET',
url: "http://example.org/some/path",
dataType: "json",
mimeType: "application/json",
headers: { "TOKEN": "%SOME_TOKEN%" }
}).done(function (data) {
// success processing
}).fail(function (xhr, textStatus) {
// fail processing
});
It could be as simple as the fact that you're missing " from the url line of your AJAX creation, but I suspect it isn't. I'm guessing that's a copying typo. This error message means your getting an uncaught exception which is bringing your app down.
Other people have reported JQuery for mobile being buggy, and having problems with certain HTTP Response statuses. I suggest bypassing it altogether, and making your own AJAX request, as a workaround (plenty of examples on the internet; I would alert the response status just so you can see what you're getting).. If that works, you can investigate whether other version of JQuery suffer from the same bugs.
Example AJAX without JQuery:
<script type="text/javascript">
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
// do stuff with xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
</script>
KERN-EXEC 3 is due to referencing a bad pointer or running out of stack space. It's probably the latter but it's impossible to say. Is there any way you can provide a call-stack?
The response of my request is a java script code. When I put the url in browser, I can see the whole generated java script code on the page. Format of url passed to $.ajax is as below:
http://localhost:8080/vi-api/viapi?action=tag&projectId=45&tagId=345
When I put the above URL I can see the request is successful. Now, I am using below Ajax request for this url using jQuery.
var finalUrl = "http://localhost:8080/vi-api/viapi?action=tag&projectId=45&tagId=345";
var req = $.ajax({
type:"GET",
url:finalUrl,
type:"script",
data:"",
success: function(html){
alert('Requese sucessful.');
},
complete:function(jqXHR, textStatus) {
alert("request complete "+textStatus);
},
error: function(xhr, textStatus, errorThrown){
alert('request failed->'+textStatus);
}
});
Question 1:This gives the alert "request failed error'. Why this is so ?
Question 2:Is there any way to return success/failure code in above process?
In:
$.ajax({
type:"GET",
url:finalUrl,
type:"script",
(...)
You have two times the 'type' key in your object. So I think only the second one is taken ('script'). Obviously 'script' is not a valid HTTP method (as HEAD,GET,PUT,POST, etc). The keyword your were looking at for 'script' is maybe dataType which may be one of xml, json, jsonp, text, script, or html.
Do not forget to look at jsonp, it's usually a nice way to return a script content and to call it.
I am not sure why, but I can give your some tips how to debug or find out issues:
1) install fiddler to look at HTTP request.
2) type:"script", why the type is script? try to use "text/html".
3) use complete(jqXHR, textStatus) you can look at HTTP status. more info about $.ajax
var finalUrl=http://localhost:8080/vi-api/viapi?action=tag&projectId=45&tagId=345;
is pretty invalid javascript. You probably meant passing the url as a string:
var finalUrl = 'http://localhost:8080/vi-api/viapi?action=tag&projectId=45&tagId=345';
I'm using jQuery 1.4.2 and am trying to perform a simple AJAX request. The target URL returns a JSON string (I validated it with jslint). The request works in Firefox and Chrome, but doesn't want to work in IE8, and I can't determine why. Here is the call:
jQuery.ajax({
url: 'http://' + domain + '/' + 'helper/echo/',
dataType: 'json',
success: function(data) {
alert(data);
},
beforeSend: function(request, settings) {
alert('Beginning ' + settings.dataType + ' request: ' + settings.url);
},
complete: function(request, status) {
alert('Request complete: ' + status);
},
error: function(request, status, error) {
alert(error);
}
});
IE will execute the beforeSend callback and the error callback. The error callback alerts with the message:
Error: This method cannot be called until the open method has been called.
My response header returns with Content-Type: text/javascript; charset=UTF-8.
What is going on with IE? I'm running the server on localhost, making a request from http://localhost:8080/psx to http://localhost:8080/helper. Maybe IE is blocking this request? I have tried installing Fiddler to analyze request traffic but it won't run on my machine because it's rather locked down. Firebug lets me, but everything seems good there.
Thanks for the help!!!
Alright, here's the fix! The request was using window.XMLHttpRequest(), which isn't working properly in IE8 for some reason. jQuery is not failing back to window.ActiveXObject("Microsoft.XMLHTTP") as it should.
Add this to your script somewhere before your AJAX call (only verified in IE8, not other IE's):
jQuery.ajaxSetup({
xhr: function() {
//return new window.XMLHttpRequest();
try{
if(window.ActiveXObject)
return new window.ActiveXObject("Microsoft.XMLHTTP");
} catch(e) { }
return new window.XMLHttpRequest();
}
});
Here's how I came to the solution:
Updated to jQuery 1.4.4 in case the issue was a bug that had been fixed.
Stepped through Firebug debugger and DevTools debugger until the results seemed to be drastically different.
On line 5899, the ajax() function creates the XmlHttpRequest object with the xhr() function. In Firefox, it was returning good data. In IE, this was returning with all fields being Error: This method cannot be called until the open method has been called.
I analyzed this function on line 5749, return new window.XMLHttpRequest();
I googled and came across this page that has the same problem and suggested the solution that works for me.
Official jQuery ticket: