jQuery - standard code yet doesn't seem to be working? [$ selector returning Null] -


I want to pass data to AJAX by looking for a perfect HTML class, then executing a jQuery action on its elements The class on completion is

It is that I have simplified, so far:

  & lt; Span class = "data_type_1" & gt; Here are some data & lt; / Span & gt; & Lt; Span class = "data_type_2" & gt; Here are some data & lt; / Span & gt; & Lt; Span class = "data_type_1" & gt; Here are some data & lt; / Span & gt; & Lt; A href = "javascript: deleted (57);" & Gt; To delete all data with id = 57, click & lt; / A & gt; Function deleted (id_to_remove) {var url = "/my.php"; // Calling with 'id = 57' class_to_remove = 'data_type_1' jQuery.ajax (url, {type: 'post', data type: 'json', data: {id: id_to_remove,}, complete: remove_callback} ); } Function remove_callback (transport) {var response = jQuery.parseJSON (transport.responseText); Var class_to_remove = response.class_to_remove; Warning ('debug point 1: square_cho_line =' + class_to_remove); $ ("Span." + Class_to_remove) .html ('Data Static Excluded'); Warning ('debug point 2: deleted'); }  

I have tested it for working AJAX calls, Callback, Data is correct on debug point # 1 (class_to_remove = 'data_type_1') ... and then nothing It does not happen, I can not get the action to execute, but there is no error message too.

The code seems basic and the syntax for the desired action is shown on dozens of web pages; Something went wrong with $ $ ('.CLASS_NAME') - when I add another debug statement, what am I missing?

Update:

Warning ($ ('. Data_type_1')); The response is null even though I can see the page source and see lots of elements with that class name.

I think this is not working because you are trying to parse the json response, which is necessary in your case is not.

You have told the Ajax call data type in the call as json . Then the returned response will already be a threaded javascript object.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -