jquery多次运行

时间:2017-12-27 02:51:03

标签: javascript jquery ajax jquery-ui jquery-ajaxq

我正在发送一个jquery ajax请求并获取一些js代码作为响应。我将响应放在div from bs4 import BeautifulSoup import csv import urllib2 import pandas as pd try: from StringIO import StringIO except: from io import StringIO sock= urllib2.urlopen('https://poloniex.com/public?command=return24hVolume') link=sock.read() soup = BeautifulSoup(link,'lxml') csv_data = StringIO(soup.text) df=pd.read_csv(csv_data,delimiter=' *, *',engine='python') df2=df.iloc[1:2,0:20] 中并使用$("div").html(data)执行脚本 但我不知道脚本为什么运行两次。 这是我的代码,它发送ajax请求广告处理响应

$("div").find("script").each(function(){
    eval($(this).text());
});

这是我的$.post("ajax-req-handler.php", { key: "barcode-input-for-sale-return", barcodeVal: $('.product-searchbar').val(), soldQty: 1, soldDisc: pickDisc, soldPrice: pickPrice, custNum: contNum, saleDate: $(".sale-date").val() }, function( data ){ $(".exec-script").html(data); $(".exec-script").find("script").each(function(){ eval($(this).text()); }); }); 文件

ajax-req-handler.php

1 个答案:

答案 0 :(得分:0)

你不需要做

$("div").find("script").each(function(){ eval($(this).text()); });

在解析HTML时执行

< script> 标记。我建议在脚本标记中使用逻辑来找到您尝试插入HTML然后插入的位置。

相关问题