jquery response add html
when I post ajax data and then alert response it adds html to it
369<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http开发者_如何学JAVA://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
...
....
I just want 369 from there...how would I do that..I dont want the complete html thanks
EDIT where do I say data type here?
var data = {
'data[id]' : $j('#Id').val(),
};
$j.post('/controller/update', data, function(response){
alert(response)
}
It shouldn't be doing that... perhaps there is an error on the page you're making the ajax call to which is where the extra html comes from... what is the exact html that you're getting that is undesireable?
Can you post the javascript you're using to make the ajax call and the entire response you're getting back from the ajax call?
Make your ajax response only Json or xml
Don't return html file or html type. Move to either Json or XML
and it should work
More documentation here
http://api.jquery.com/jQuery.ajax/
example
$.ajax({
type: "GET",
url: "localhost/getsomepage.aspx",
dataType: "xml",
success: function(xml) {
}
});
Explicitly set the dataType in the ajax call:
$.ajax({ url: 'myurl.php', dataType: 'text', success: function(data) {console.log(data)} });
精彩评论