please helppp :/
I swear to GOD this things was working yesterday pretty well. Just broke today, dont know why.
but the done callback from $.ajax is not firing.
function check() {
$.ajax({
url: "/statistics/setup-Table",
dataType : "json",
success: function(data){
alert("check "+data['total']);
}
}).done(function(){
alert("done");
}).fail(function(){
alert("fail");
}).always(function(){
alert("always");
});
}
i only get one alert >> "check 24"
no alerts from done, fail or always pops up. even for the other $.ajax calls, callback functions are not getting fired.
The url is fine too.
Thanks in advance.
It was the version I was using of Jquery that messed things up. the CDN that is.
Kevin B - thank you much .that really helped.
Thank you to all the rest as well who looked into it for me .
You guys r amazing, i love this community. i hope i can help back as well ..
later guys. :)
Related
I am working inside of an Oracle package. I am trying to use an AJAX call to call a procedure from a button click. The ajax call is inside of a function. I am not getting any syntax errors from Oracle or when I'm using the browsers debug mode so I'm not sure what the problem is. Function is below.
htp.p('
function ApplyTest(_ht) {
var _inst = "";
var _pidm = '||v_web_pidm||';
var _inst = document.getElementById("Test").value;
alert("Heat Ticket value is: " + _ht);
alert("the instance is: " + _inst);
var resp = confirm("Are you sure you want patch applied to TEST8?");
if (resp == true) {
alert ("user pidm is: " + _pidm);
return $.ajax ({
type: "POST",
cache: false,
dataType: "json",
url: "gyapatch.p_update",
data: {"v_instance" : _inst, "v_ht" : _ht},
success : function(data) { alert("success"); }
});
alert("Got here");
alert("value: " + _inst);
window.location.reload;
alert("got to the end");
} else {
return;
}
}
');
code for the button is:
<button name="TestApply" id = "Test" onclick="ApplyTest('||val_patch.heat_ticket||')" type="button" value="T">Apply to TEST8</button>'
When I try to return the ajax call nothing is happening and I can't even reach the "Got Here" alert. When I remove the "return" keyword, I can reach the alerts but either way, nothing is happening. GYAPATCH.p_update is the package/procedure I wish to have executed when this is ran
I'm not sure what the problem is. Any help on this would be greatly appreciated. Thanks in advance.
So after a couple of hours, I had figured out the problem. This was more of a learning lesson as the issue was pretty simple. I needed to remember that I was working inside of an Oracle database AND also using WebTailor. The code posted above is correct. It turns out that the procedure I was trying to call (p_update) was not registered.
WebTailor allows you to build web applications utilizing Banner. In WebTailor, any pages that are used (usually stemming from a package.procedure), need to be registered or else they are not recognized.
I found this while debugging. Under the Network tab in my debugger, I noticed that when I click my button, I am getting a 404 error when my package.procedure is called. So I then realized it couldn't find my package and then proceeded to check if it was registered. This was a simple, silly error on my part. I am grateful for the feedback, but this will probably serve as a learning lesson or reminder to anyone trying to use ajax while working with Banner data.
I have been wrestling with a weird error for quite some time now. I want to believe that this is one of those errors where the solution will just slap me in the face, but we shall see. Here's the code:
var images = {};
// Set Image Gallery
function setImageGallery() {
// Get Product JSON
$.ajax({
url:"JSONimages.php"
data:{
"table":"belts"
}, // Firefox says this } is missing... but it's here.
success:function (data) {
images = $.parseJSON(data);
alert("Got Images!");
}
});
}
And here's the code snippet being pulled from an AJAX Request:
<script type="text/javascript">
setImageGallery($("select[name=imageGallerySelect]").val().toLowerCase());
</script>
<h2>Edit Image Gallery</h2>
<p>Select Gallery: <select name="imageGallerySelect" onchange="setImageGallery()">
<option>Belts</option>
<option>Gallery</option>
<option>Home</option>
<option>Hybrid</option>
<option>IWB</option>
<option>Knives</option>
<option>OWC</option>
</select></p>
<form action="">
<p>Image:<br><input type="file" name="image"></p>
<p>Price:<br><input type="text" name="price"></p>
<p>Description:<br><textarea name="description"></textarea></p>
<p><input type="submit" value="Save"></p>
<div id="thumbnails"></div>
</form>
Now, in the process of debugging, I changed the $.AJAX() method to directly set the value of "table" for my PHP (which outputs JSON) script to "belts". I'm getting mixed results. Chrome is telling me it's an error from the JQuery Script itself. Firefox says there's a missing "}" at the spot where I put the little comment in the first code sample. I've toyed with the script with zero luck. It's errors like this that let me know I have a lot to learn :/
The anonymous success function never gets run and the alert doesn't pop up, of course. I'm hoping this is a stupid error and that I'm making a newb mistake here :)
You are missing , after the url parameter:
url:"JSONimages.php", //<-------------- this comma you missed
data:{
"table":"belts"
},
Oh god, I saw it as soon as I submitted the question. The function setImageGallery() does not accept any variables, but I pass it a string!
Wait, no. That was a stupid mistake, but I'm still getting an error. Help? Firefox error reads: "SyntaxError: missing } after property list". Chrome insists that the error is on Line 2 of the JQuery Library. I don't know that either of those errors are very useful. The } is there. The JQuery library is flawless. I want to believe that I'm somehow screwing up the $.ajax() call, but it worked when I used it elsewhere.
Sorry for my english. I get the message of "too much recursion", and i think is in the ajax, here is the code:
function procesarPdf(carpeta,idRevista,dirarchivo,paginaProcesar,nombreArchivo){
$.ajax({
type:"POST",
url:'php/procesar_pdf.php',
data:{carpeta:carpeta,revista:idRevista,archivo:dirarchivo,paginaProcesar:paginaProcesar,nombreArchivo:nombreArchivo},
async:false,
cache:false,
success: function(data) {
var datos = data;
if(datos.terminado==false){
procesarPdf(datos.carpeta,datos.idRevista,datos.archivo,datos.paginaAProcesar,datos.nombreArchivo);
} else {
alert("Finish process");
quitarEspera();
}
}
});
}
I use pdf to process images to get images and thumbnails whit the file procesar_pdf.php.
When sucess i call again the function to continue the process and i use progressbar of jquery to see the progress, but when the progress is in 50% or 56% or 65%, the firebug throw me the message of "too much recursion" with other error how "css.Fn" or "showHide(this,arguments)".
I dont know the error, please tell me if know the error.
You are calling the function
procesarPdf(datos.carpeta,datos.idRevista,datos.archivo,datos.paginaAProcesar,datos.nombreArchivo);
from within the function procesarPdf - too much recursion would indicate that this is happening many times. Each time a function calls a function a new frame is added to the stack, and there is a limit to how deep the stack can be. You should pursue an alternate strategy for continuing the processing, especially if you want to do it synchronously.
Without seeing the rest of your code, it looks like you might be recursively calling the procesarPdf() too many times in whatever you are doing. Here is a post that gets at the root of why another user was having a similar issue and getting the same error.
I am using the Javascript setInterval to keep polling the server for any updates and refresh the screen with the response from the server. I need to support >IE7, and other major browsers.
The setInterval function is getting fired in all the browsers except IE7 and IE8.
According to the suggestions I saw in other posts I have tried setting cache:false on the ajax requests as well as wrapping the setInterval call in an anonymous function. But none of the suggestions seem to work.
Following is the code I am using:
$(document).ready(function () {
setInterval(pollForServerUpdates, 30000);
});
function pollForServerUpdates() {
$.ajax({ url: $.url("Home/GetUpdates"),
type: "POST",
cache: false,
success: function (result) {
updateTabelWithCurrentStatus(result);
},
dataType: "json"
});
}
I am not sure if I am missing anything here. Any help is very much appreciated.
Thanks!
I am putting my comments above as the answer to this question. The issue was happening because "class" seems to be a reserved keyword in IE and causing an error. When creating the element, I wrapped the class keyword in quotes and all is well. Thanks Pointy for asking me to look at the console. #Spudley, thanks for the tip, I will be refactoring my code with your suggestion.
I had jQuery autocomplete working perfectly with CodeIngiter when inexplicably it just stopped functioning completely. When I visit the controller for the autocomplete I still see the correct array - Javascript just isn't returning the JSON data. What makes this weird is that it was working fine, and then out of the blue just stopped working.
Here's my Javascript:
$( "#clubs-complete" ).autocomplete({
source: function(request, response) {
$.ajax({
url: 'http://www.myurl.com/create/autocomplete',
data: 'term='+$("#clubs-complete").val(),
dataType: "json",
type: "POST",
success: function(data){
alert(data);
response(data);
}
});
},
minLength: 1
});
Here's my controller:
public function autocomplete()
{
// Search term from jQuery
$term = $this->input->post('term');
$this->db->select('name','address2');
$this->db->from('clubs');
$this->db->like('name', $term);
$suggestions = $this->db->get()->result();
if (count($suggestions) > 0) {
$data = array();
foreach ($suggestions as $suggestion) {
array_push($data, $suggestion->name);
}
// Return data
echo json_encode($data);
}
}
Does anyone have any idea what's going on? The alert in the javascript function returns nothing now, and it used to. When I visit the URL directly I still see the full array.
Please help, I'm tearing my hair out.
In IE there are developer tools available if you press F12. There's something similar in Firefox called Firebug. In either of these you can debug in-browser javascript. Set breakpoints inside the source fn and also within the success function, it may give you some insight.
You also may want to get an http debugging proxy, something like Fiddler2 or Charles, which will let you see outgoing HTTP requests and their corresponding responses. Fiddler2 runs on Windows and works with FF and IE, and pretty much every other http client. This will let you see the messages that your AJAX service is returning to the in-browser javascript.
Those things ought to give you insight into the "not working" problem.