AJAX success getting a certain value of object

The River Scene Music

So I'm polling my server for information. Below is what I get back through firebug, but I'm only wanting the new notifications to post into their div if the response.notification_status value of 1 is met. Because as soon as it polls it again that very notification is set to the value of 2.

 {"num":1,"notification_id":"783","notification_content":
    "Lucy  Botham posted a status on your wall","notification_throughurl"
        :"singlepoststreamitem.php?streamitem_id=663","notification_triggeredby":"85",
    "notification_status":"1"
        ,"notification_time":"2015-11-08 01:58:22"}

And my actual success and what I've tried.

success: function(response){
if(response.notification_status = 1){
//PREPEND NOTIFICATION
}
Tonlage

The problem right now is that the operator =, that you are using in your if statement is the assignment operator, and cannot be used to compare values. What you need is the == operator. So you would need to do something like this:

success: function(response){
if(response.notification_status == 1){
//PREPEND NOTIFICATION
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery AJAX success for certain form

From Dev

Getting the highest value excluding a certain value from a nested object property

From Dev

Getting Certain values from an AJAX return JSON object

From Dev

Json object is empty in success of ajax

From Dev

.ajax returning json object, but no success

From Dev

Access JSON Object in ajax success

From Dev

ajax success return value complicated

From Dev

PHP AJAX success value empty

From Dev

Karma testing with .success() getting 'undefined' is not an object'

From Dev

Karma testing with .success() getting 'undefined' is not an object'

From Dev

Getting a specific value from a jquery object passed through an ajax request

From Dev

how to access object method inside ajax success

From Dev

Reading object from success function of $.ajax

From Dev

Uncaught Type Error in AJAX success object

From Dev

return value from ajax success function

From Dev

Passing value from click (this) into ajax success in jQuery

From Dev

Updating a cell value after each ajax success

From Dev

On ajax success, change another link value

From Dev

Ajax success returns but no value is inserted in database

From Dev

0 value is returned on success result in ajax in wordpress

From Dev

Getting 'unterminated object at' when trying to get value of certain key from JSON

From Dev

getting value of a JSON object

From Dev

Getting key and value of object

From Dev

getting value of a JSON object

From Dev

Getting object value

From Dev

Js Object - Getting the Value

From Dev

json value getting it as "[object Object]"

From Dev

compare the current value with previous value of ajax success callback

From Dev

Change certain value of a JSON object

Related Related

HotTag

Archive