JQuery :: Conditional Statement In $.ajax Call

Dec 28, 2010

I'm trying to write a modal login script which I borrowed from the SimpleModal site. Unfortunately, I'm running into a very frustrating problem.

When the user types in a valid login/password combo, the PHP function do-login.php echos back "OK". That being said, here's a snippet of my jQuery code:

$.ajax({
type: "POST",
url: "do-login.php",
data: str,

[Code].....

The do-login.php script DOES echo back "OK"- I verified that with Firebug. But even though it echos back "OK", it goes to the 'else' clause.

I tried using return instead of echo but that didn't help either.

View 18 Replies


ADVERTISEMENT

JQuery :: Figuring Out - Use A Conditional Statement If Children Exist?

Jun 18, 2010

So I'm new to jQuery and loving it! I just got stuck on a problem that I'm not sure how to work around. I'm trying to add a class to a li item in a navigation if it has child list items underneath it. For example,if I have this situation:

[Code]...

View 1 Replies View Related

JQuery :: Posting To A Php Page - Unable To Use A Conditional Statement With One Of The Variables?

Nov 11, 2011

I am posting two variables to a php page:

$.post('poll_receiveData.php', {question:currentSlide, vote:vote},
function(output){ ... })
}

currentSlide is set to 0. vote is set to 2. When I look at my console log, these are true. But in poll_receiveData.php, I'm unable to use a conditional statement with $vote. It's like the program doesn't know how to compare things to $vote. But a SQL statement using $question works just fine. Here's my code:

[Code]...

View 1 Replies View Related

JQuery :: Conditional Statement - No File Extension - Leave The Default Styling ?

Mar 8, 2011

JQuery and I have a function which adds an image to a link depending on the file type.

How to write a statement that says....if there is no file extension - leave the default styling, if not add file extension. At the moment I have dots and images..see here [url]

View 8 Replies View Related

Conditional Statement W/i A Loop Correct Syntax

May 3, 2011

Code? What is the correct way to write it.

Rules: create an array for the user to type 5 strings in a prompt that will be displayed in an alert box.

User must type in the prompt an alert will display what the user typed if the prompt is empty or contains nothing an alert will display telling the user to enter text user clicks ok on the alert box and is sent back to the prompt box

View 14 Replies View Related

Conditional Statement Doesn't Work Correctly

Dec 6, 2009

Code:

Red part in the code above is for conditional statement.

But the conditional statement doesn't work correctly.

How can I make the conditional statement correct in javascript?

View 24 Replies View Related

Simple Conditional Statement - If Click Yes - Take Them To The Form - If No Then Redirect Them To A Different Page

Apr 13, 2010

I am not a javascripter however I have a simple need to a yes no question before someone can fill out a form. Bloew is what I have. If they click yes I'll take them to the form, if no then I will redirect them to a different page. I can not get it to work.

Code:

View 2 Replies View Related

Beginning - Conditional Statement Based On What Button A User Clicks

Feb 20, 2010

I am starting to learn javascript and I had a quick question. I know actionscript and java, so this my mistake here is probably context...but I cant seem to figure it out. I'm trying to figure out how to create a conditional statement based on what button a user clicks. Here's my code:

[Code]....

This doesn't seem to work. Am I referencing this.value incorrectly? If so, what's the proper way to get information about what the user clicked?

View 4 Replies View Related

Jquery :: Conditional Css - Call A Function To Check If A Div With Id Content Has A <h1> Tag And If So Change Divs Background Colour

Mar 25, 2009

I'd like to call a function to check if a div with id content has a <h1> tag and if so change the divs background colour.

View 7 Replies View Related

CSS And A Conditional Statement - Trigger The Fade-in/fade-out Functions Of The Span Class Is NOT Set To Active?

Jun 20, 2011

I found this script for a navigation fade-in/fade-out and I want to modify it so it'll only trigger the fade-in/fade-out functions of the span class is NOT set to active. Here is the javascript:

Code:
$(function() {
$("#nav ul#menu li span.active").css("opacity","1");
$("#nav ul#menu li span.active").hover("opacity","1");[code].....

It's the part of the code beneath the comment CONDITIONALS BELOW that I want to be able to only trigger it if span is not set to class .active.

View 1 Replies View Related

Call A Function In A Meta Refresh Statement?

Jan 18, 2010

Is there a way to call a javascript function in a meta refresh statement? I'm refreshing my page but if I have data in my fields I don't want to loose them. If I can call using a JS function then in that function I can call the Submit function and save my data in the called script.

My syntax below doesn't fire the JS function:

<meta http-equiv="refresh" content="30;url=javascript:auto_refresh();">

View 1 Replies View Related

Change Background Image With If Statement Or Call Function Inside Of If?

Jan 17, 2010

Basically I want to have a different background image for every time of the day. The function by itself works okay with onclick or onload placed in body.

function changesky()
{
document.getElementById("sky").style.background="url(back_morning.jpg) repeat-x";

[code]....

View 5 Replies View Related

AJAX :: Call Based On Results Of A Previous Call

Dec 14, 2010

The general framework is a simple user login function. The user name is selected and a password entered as usual. The function grabs the element values and passes them to a php page that queries the database. An AJAX call returns the password to the function and then I want the innerHTML to be a choice of two web pages, depending on success or failure of validation. There are existing AJAX functions available on the internet but they are overly complicated for what I think should be a simple, quick to load function.

Where I am stuck is that the standard procedure to make an AJAX call is the browser window event. How do you make the call from within the function? I have tried creating two new variables, "success" and "again" to replace xmlhttp, but still stumble on the event to assign a value. I left the blank password protection (if statement) with that variable to demonstrate what I mean.

I've put in my code below, which is in development and successfully alters the innerHTML text depending on user input but I can't figure out how to insert the relevant php page. I have '// out' the testing bits, but left them for info. (I have tried full 'scripting' as the innerHTML, but it's messy.)

View 4 Replies View Related

JQuery :: Call Web Service With Ajax

Mar 16, 2011

I wrote the following code with Dreamweaver:

If I run it in Dreamweaver It works and the alert success is raised, but If I run this code into Safari or Chrome the Error alert is always raised.

View 1 Replies View Related

JQuery :: How To Get UI Widgets Via Ajax Call

May 10, 2011

My goal is to get some HTML content including some UI widgets and other stuff via an ajax call. To clarify my goal and the strange behavior, I attached some HTML files, that you can run for yourself. Open the index.html will show you some UI widgets, which are pulled from the ajax.html via ajax. When you scroll to the bottom you can see the same content inserted a second time. But this time, the widgets are not "rendered". It looks if the "button()" calls etc. are not executed.

The only difference is the way I insert the result of the ajax call. The first time I insert the hole content received by the ajax call, the second time I only insert the content of a special div. The goal in this is to get various chunks of content with one ajax request and replace "div#one" and "div#two" with different parts of my site. Which is not working. Is it generally okay to receive html content which has some script parts to be executed via ajax and what is wrong with my second approach?

View 1 Replies View Related

JQuery :: Cannot Return Value After Ajax Call

Aug 9, 2009

I'm currently using the dialog functionality (modal form) from UI library to submit data to the database. All the validation checks have been running ok until one of the validation checks requires a ajax call to check if a username exist in the database. I'm fairly new to both javascript and jquery so this could be a fairly basic blunder. Initially, i thought it was an synchronicity problem, but I changed the $.ajax async option to true but still no joy, so maybe it something to do with scope etc?

Here's the code:
function checkIfUsername(){
$.ajax({
type: "POST",
url: ""+CI_ROOT+"index.php/admin/check_if_username",
data: ({username: username.val()}),
async: false,
dataType: "json",
success: function(data){
returnUsernameBool(username, data);
}});
}function returnUsernameBool(o, data){
if(data.bool == true){
o.addClass('ui-state-error');
updateTips("Your username must be unique");
alert('false'); //this works
return false; //still can't return bool
}else{
alert('true'); //this works
return true; //still can't return bool
}}
bValid = bValid && checkIfUsername(username);
alert(bValid); //still gives undefined

View 5 Replies View Related

JQuery :: Use Attr In An Tab AJAX Call?

Sep 6, 2009

I am trying to set an html attribute after an AJAX call. Works great on the initial tab I can't get it to work on the rest [code]...

View 1 Replies View Related

JQuery :: Return Value From .ajax Call

Jan 25, 2011

Is it possible to get a return value from a page call within an ajax call? For example,

$("#new_request").click(function(e){
$.ajax({
url:"_insert_new_request.php",
type:"GET",

[Code]....

Here I make an ajax call from a click on a div. I then call "_insert_new_request.php" page, with a param of "partner_id_link".

Can I return a value from the "_insert_new_request.php"? and how?

View 1 Replies View Related

JQuery :: Using AJAX To Call PHP Script?

Jul 6, 2010

I am planning to use an AJAX call to a PHP script that accesses a REST servlet. My php script would be very simple; something like:

[Code]..

I'm an experienced programmer, but I'm fairly new to web development, so I am having trouble interpreting this error. What have I done wrong? Is this the proper way to call a PHP script with AJAX?

View 1 Replies View Related

Ajax :: Script Update Doesn't Work Without Alert() Statement?

Nov 19, 2010

I have a JavaServer demo I'm working on with a bit of JavaScript and thought I'd try adding some AJAX. Its a forum, and the idea is that a post window is revealed when the reply message is clicked. This button is in a jsp page has an onclick attribute to the showEditor() function below. A cancel button is similarly hooked up to hideEditor(), and the submit button calls copy() with a onsubmit tag. A servlet sends a response which has both the HTML for the post area (its a rich-text editor in an iframe, with a bunch of buttons above it much this one) and a Javascript object called Editor that has handlers for all the buttons and sets up the iframe so it is editable.

I actually got it to work okay, until I removed the last alert() I was using for debugging. Then the iframe stops being editable, and the editor.appendQuote() function either doesn't work or doesn't run.

This isn't terribly important because all AJAX accomplishes here is not sending all the post-related HTML and Javascript unless it is actually needed, which isn't all that much, but it would be nice to figure it out anyway.

Code:
<script type="text/javascript">
var editor = null;
function showEditor(node) {
if (node != null) {

[Code]....

View 2 Replies View Related

JQuery :: Accessing A List After AJAX Call

Apr 9, 2011

I have a page that creates one unordered list from the contents of another list. The second list is created from a database query and is hidden on the page. I have written a JQuery function shown below that does an AJAX call which causes the hidden list to be created and that is working perfectly. The problem is that when the code following the AJAX call is executed it doesn't see the hidden list. The alert message displays 0 the first time. clicking on the Load button a second time results in the first list being displayed. If I click on the Load button a third time, the previously loaded list is displayed; click on a fourth time and the new list is displayed.

In other words, it takes two cycles to display the correct list. I am at a loss as to what might be the problem. Other than this issue the code does what I need it to do.

$(function() {

View 2 Replies View Related

JQuery :: Ajax Call - 403 Forbidden If URL In Content

Oct 15, 2010

Strange behaviour: User enters text into textarea - text includes URL with protocol e.g. [URL]. JSON call fails with 403 forbidden. It seems the the serialised content is being interpreted as a cross domain call (my guess). Any other text works - Even if the user enters "http://www.u", but as soon as the input qualifies as a url, I get a 403.

The code extract:
var formText = $("#contributioncontrol").serialize();
$.getJSON('[URL]',formText, function(response) {
if (response.ERROR != true) {
var output = response.HTML;
$(output).hide().prependTo("#results").fadeIn("slow");}
}

If the user enters http://www.url.com in the textarea on the form then The request looks like this: [URL]. The '/' chars in the line above are replaced by% 3 A % 2 F % 2 F (without spaces - Don't know how to stop browser interpreting the encoded stuff).

And the response like this:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /API/createcontribution.php on this server.</p>
<p>Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.mysite.com Port 80</address>
</body></html>

View 1 Replies View Related

JQuery :: Ajax Call Doesnt Work In IE?

Jul 5, 2010

i have a set of select fields, which when selected, send a value via ajax, to return a sub-selection for further choice. I have 3 levels of sub-categories like this. For some reason it works in FF only - not IE. [URl]..

View 12 Replies View Related

JQuery :: Ajax Call When Clicked On A Link

Feb 16, 2011

I am using an ajax call when clicked on a link... It asks whether you want to continue or not and if you say "ok" then it uses a perl script to delete something from the db.[code]So I was able to call confirm on each of those links and if agreed use an ajax call to a perl script to wipe the user from database. The thing is that I had to usereturn false; in the end of my js call (after ajax) otherwise the link would take me to the script, which I dont want to. I want to remain at main level (to be able to see all users)... Now how do i refresh the page after such deletion? Lets image this scenario:

User clicks on link_to_delete Brad => confirm => he confirms by clicking ok => ajax call to perl script that handles the deletion of Brad => return false (I want to remain at index.pl) => HOW DO I REALOAD INDEX.pl ? I deleted Brad but I can still see him cause the page has old data.

View 4 Replies View Related

JQuery :: Append Parameter To Url During Ajax Call ?

Nov 16, 2010

I need to append a parameter during an ajax call: I was thinking about something like below:

The problem seems to be with the ajaxSend parameters. It seems that I cannot modify none of them:

View 1 Replies View Related

JQuery :: Checkbox Change Ajax Call?

Mar 29, 2011

I'm having problems with jquery and checkboxes..I've been trying and debugging for some time now, but I can't fix it.This is my current code:

[Code]...

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved