web123456

ajax returns object Object Solution

Phenomenon: Use ajax to send requests, because of the background php, Alibaba's text messages were used. Later, the return type object Object. I saw in the browser that the return format is like this: {msg:90,ok:ok}[1,#98978]. Ajax return value is not easy to deal with. {msg:90,ok:ok}This is the return value of a third-party SMS and cannot be removed. [1,#98978] This is the return value you need to use in the background.


If the return type is complex and just returns a field, you can use complete to accept the callback function, and use the return result as a String, and just intercept the string.


Solution:

<span style="white-space:pre"> </span><a href="http://s.">click</a>$.ajax({
                     type: "post", //Submission method
                     url : "../",//path
                     async:true,
                     dataType:"json",
                     data : {
                         "xxs":xx,
                         "xx":xx,
                         "xx":xx
                     },//Data, here is used in Json format for transmission
                     complete: function(data) {//Return data and process it according to the result. Regardless of whether the request succeeds or fails, this method will be followed.
                    	 var str=;//Convert the return result into a string. At this time, the mark "#" in the future station (defined by yourself, mainly used to intercept the string) is mainly used to mark the "#" (defined by yourself, mainly used to intercept the string)
                    	 if(("#")>0){
                    		 var do=(("#")+1,18);
                    		 ="?xx="+dd;
                    	 }else{
                    		 alert("Save failed, please try again later");
                    	 }
                     }
                 }); //ajax_end