Clicky

after a form is submitted I have a success function:

success: function(data) { ....

what i want to do is check to see if data contains a div with a specified class.
if yes then display that element and if no then continue on as normal.

thanks

asked 12/08/2011 10:24

dgrafx's gravatar image

dgrafx ♦♦


10 Answers:
will help you to get the controls with specific css name
$(".classname")

Take a look into the sample

http://api.jquery.com/class-selector/
link

answered

santhimurthyd's gravatar image

santhimurthyd

i've seen this link
i'm unable to find the correct syntax
that's why i asked the question
link

answered 2011-12-09 at 06:45:25

dgrafx's gravatar image

dgrafx

check this


$(".classname").each(function(index) {
    alert(index + ': ' + $(this).text());
});
link

answered 2011-12-09 at 06:52:28

santhimurthyd's gravatar image

santhimurthyd

so where are we inputting data (as in function(data)) ?
link

answered 2011-12-09 at 07:16:17

dgrafx's gravatar image

dgrafx

Yes,

For more info, you can get it here
http://api.jquery.com/each/
link

answered 2011-12-09 at 07:18:39

santhimurthyd's gravatar image

santhimurthyd

here is the solution:
success: function(data) {
$('.zzz').html($(data).load($('.xxx'))[0]);
}

after submit - this will take the element whose class is xxx and put it in the element whose class is zzz

one could use an id if wanted instead
link

answered 2011-12-09 at 07:20:54

dgrafx's gravatar image

dgrafx

I've requested that this question be closed as follows:

Accepted answer: 0 points for dgrafx's comment http:/Q_27486084.html#37262614

for the following reason:

The solution is provided<br />thanks

link

answered 2011-12-09 at 08:08:29

dgrafx's gravatar image

dgrafx

Do you have got your solution from the comments else by your own.
link

answered 2011-12-09 at 08:09:19

santhimurthyd's gravatar image

santhimurthyd

of course i derived the solution on my own and from googling.

it's not a problem but all you did was post a couple links that did not address the issue.

have a good one ...
link

answered 2011-12-09 at 08:37:56

dgrafx's gravatar image

dgrafx

solution is provided

link

answered 2011-12-09 at 08:41:03

dgrafx's gravatar image

dgrafx

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

Asked: 12/08/2011 10:24

Seen: 248 times

Last updated: 12/16/2011 05:15