我无法将数据检索到 jquery div 元素,但我可以在 firebug 中看到 ajax 响应。
$(document).ready(function () {
$.ajax({
url: "https://m.lowes.com/CatalogServices/product/nvalue/v1_0?nValue=4294857975&maxResults=6&showURL=1&rollUpVariants=1&showUrl=true&storeNumber=0595&priceFlag=rangeBalance&showMarketingBullets=1&callback",
dataType: "jsonp",
success: function (data) {
var returnedData = JSON.parse(data);
$('#result').html(returnedData);
}
});
})
Run Code Online (Sandbox Code Playgroud)
这是我的响应。例如我的 url 包含数据 productCount:64 ,我应该从 ajax 成功中提取 productCount 并将其显示在 html div id 结果中
我是新来的反应,我收到状态和方法的错误:
./src/App.js
第 5 行:'state' 未定义 no-undef
第 8 行:'inputchangehandler' 未定义 no-undef
这是我的代码,直到现在:
import React from 'react';
import './App.css';
function App() {
state = {
userInput: ''
}
inputchangehandler = (event) => {
this.setState = ({
userInput: event.target.value
})
}
return (
<div className="App">
<input type="text" name="name"
onChange={this.inputchangehandler}
value = {this.state.userInput}/>
</div>
);
}
export default App;
Run Code Online (Sandbox Code Playgroud)